If a company wants to increase productivity, then they should provide greater ownership and autonomy to workers, as well as better incentives such as profit sharing. If an engineer knows that they'll get a cut of the cost savings or profits of some project idea they have, then you can bet that many employees will take advantage of that to get valuable work done.
If I were running a company, I'd hire remotely from the global talent pool, and more importantly ensure that my employees are actually incentivized to get things done via ownership and profit sharing.
It's a shame that executives at big tech companies are opting for the authoritarian approach, and I firmly believe that that will be their downfall. There certainly is value to in-person collaboration, but forcing it via threats is absolutely not the right approach. A better way to incentivize workers returning to office would be via positive incentives (eg. more money, subsidized housing, free transportation) as opposed to negative threats (eg. firing people for not obeying the lord's commands)