I own several companies that have a large pile of transfer pricing agreements, I’m very familiar with the nature and complexity of international tax laws. All corporate tax avoidance is, is incurring offshore expenses to shuffle profits offshore. As long as you can do that, there is literally no way to prevent the tax avoidance. The only thing you can do is make it more complicated.
This is also the reason most developed economies have given up on regulating transfer pricing any more than they already have, and instead the strategy has shifted to trying to get the tax havens to implement or increase their corporate taxes. That’s why the “global minimum corporate tax rate” idea has recently emerged, and why the EU uses their black and grey lists to coerce foreign jurisdictions to write new tax laws. This strategy is arguably more effective, but still a complete failure, because you have some tax haven jurisdictions that simply ignore the pressure, and other tax havens are simply never sanctioned because they have sufficient leverage in the global economy to avoid the attention entirely.
It is very literally a choice between corporate tax, or globalization. There is no way to have both.