And it would be absurd if they could not.
Also, in some cases, employers should be able to discriminate, it's totally different to hire someone on an n-month visa vs full time.
Granted, it's different if they are Green Card.
It's also perfectly normal to want to hire locals, if it can be done on a national basis, then I think for some roles, state ought to be fine as well. If state governments had a state preference for in-state nationals, that would be fine, for example.
The issue here is by far and away mostly one of transparency and efficiency - the rules should be clear and the bureaucracy should just function normally.
The fact that anything takes months, or that you need lawyers etc is a sign of dysfunction.
It should be about as complicated as getting a prescription. 'One trip to an office and done'.
For those seemingly not believing this, read: [1]https://www.avvo.com/legal-answers/can-a-company-refuse-to-c...
So, yes, they could hire a citizen, but then they probably wouldn't be able to do the job they were hired for.
This is based on my experience in working with good immigrant coders who got the job over about equally capable locals, but more cheaply. The immigrants (mostly Indian and Chinese) tended to have weaker English communication skills but stronger work ethics.
Nobody has 20 years of React experience, of course, but that doesn't stop people from listing this as a requirement - or a pre-selected group of people on the other end from asserting this experience.