The current wave of layoffs are coincident with the rise of significantly novel AI algorithms that will create a ton of new opportunities. There are going to be 1000s of AI startups, more than there would have been without these layoffs. If immigration laws force highly skilled developers to return home, then many of those startups will be located outside of the US. This would be good for their home countries, and less so for the US.
A personal tragedy for those who have build up lives here and will see that destroyed in a matter of months, but a net benefit for the rest of the world in the long run. It is things like this that reduce discrepancies between developed and developing nations - whether intentional or not.