I would say "intent" of law, rather than what actually happens. e.g., the reason we call tax loopholes, "loopholes", is because the consensus is that they're being used to defeat the intent of law.
Megacorp with a shell company of zero employees in Ireland using the double irish[1] I think means the company isn't paying their "fair share".
Fairness is defined by law? Interesting idea. By "fair share" I mean, unsurprisingly, a share that is fair. Corporations are subject to taxation. A corporation that makes healthy profits, in part driven by publicly funded infrastructure, should be required to give back to maintain said infrastructure.
Typically corps accused of avoiding tax earn no profits after their myriad coats are applied, that's how they avoid taxes. While governments could probably do more to charge corps tax, this is a complex grey area and there is no simple way to define fair or collect taxes as accounting rules are so complex. If you tax revenue you penalise new companies, if you tax profit it is easy for corps to find costs or transfer funds to shield profits.
They play lots of shell games to hide the profits, yes, and it is complex. I'm more talking more about the big picture than specifics because, as you point out, this is an involved topic which involves a great deal of money. A lot of effort has gone into creating arguments to justify the idea that workers should have to pay all costs of public infrastructure.