So if you’re legitimately based in a country with low or no corporate income tax and you make $1 of profit in the US and $1b overseas, you pay the US tax on your entire income? Who would agree to that? It would also be a flagrant violation of world trade rules.
This is an example of where the perfect is the enemy of the good. The point here is to capture the (now) trillions of multinationals that are made almost exclusively in the developed world but aren't taxed anywhere near reasonably anywhere in the developed world.
Laws can be written to say things like "substantial operations" in the US. Software engineers tend to have a problem with the discretionary and subjective language that is common in the law. But such language would allow the likes of the IRS to capture most of the squirrelled trillions. And if some of it isn't who cares?
In case you're not from or familiar with the US system, there are countless examples of this. Take sales tax. By the US constitution, the Federal government has the right to tax interstate commerce. The states don't. This led to a problem in the Internet era where people were shopping online and Internet retailers were under no obligation to collect state sales taxes. Technically consumers were liable for them anyway (so-called "use taxes") but many never reported them.
Companies with a presence in the state however were obligated to collect those sales taxes as their presence made them subject to state laws. This is why if you shop from B&H or Adorama you only pay taxes if you live in the state of New York (NJ too for Adorama IIRC).
But some years ago the state of New York went after the likes of Amazon with a so-called "Amazon tax". Such a move by the states was inevitable and I believe now Amazon collects sales taxes everywhere. This puts them on the same footing as the likes of Walmart.
So there are still retailers around that are small enough they don't merit the Amazon treatment but who cares? The point was to get to a "good enough" solution rather than a perfect solution.
Perfect isn’t enemy of the good. There is a perfectly good solution, don’t tax profits st the corporate level, tax them at the individual level.
If you eliminate corporate income tax and compensate by making captital gains and dividends ordinary income so you paid regular income tax rates on them, you’d encourage more US investment. There would be no repatriation or tax loophole issues. Hundreds of thousands of tax accountant accountants would be freed to work on actual value creating activities.
Apple shareholders lose 50-70% of dividend payouts to 5 layers of taxes. That’s true of the wealthy as well as the poor retirees on fixed incomes. Eliminating corporate taxes means the retirees pay very little tax while the wealthy still pay over 40% state and federal. That’s what progressivity should look like.
This isn't an issue of poor enforcement. Unlike the state sales tax problem, it's not that taxes that are legally owed not being paid. To go with your metaphor, you're proposing New York ask for some new tax for sales made in Oregon (which has no sales tax) if you have an office in New York because they think it's unfair that Oregon has no sales tax.
That some companies are getting low effective tax rates largely comes down to incompetent tax regulation in the EU and a few of its member states. If they really want that money so bad, they can change their laws. The US shouldn't try to take it until they do. If nothing else, when the EU does get around to fixing its laws it would be a nasty shock to the department of the treasury as that money stops flowing in.