The premise that the law doesn't apply because you're not in the country is false. The constitution applies generally everywhere to all Americans, it's just that what's regarded as reasonable differs during a border search. IANAL, so just my lay opinion on this. Just to validate this, it's only because the constitution exists that the border authorities have any legal basis in doing inspections.
> On or about January 24, 2025, in the Northern District of Georgia...
[1]: https://storage.courtlistener.com/recap/gov.uscourts.gand.35...
But in general, the thing to note here is that the 4th amendment is always applicable and in force. It's how it's interpreted that changes depending on the circumstance.
> While the Supreme Court has long recognized a border-search exception to the Fourth Amendment’s warrant requirement, it applies to only two interests: promoting the duty regime and preventing contraband from entering the country; and ensuring that individuals are legally admitted. The government’s recent use of the exception goes substantially beyond these matters.
None of these two interests apply to his targeted search. No duty applies here. By definition, no contraband can exist on an erased phone