So if I'm reading this right, this seems to be about PERM applications.
For context, PERM certification is a required step in the green card application, where a company sponsoring a green card applicant must demonstrate that they posted a job ad for the candidate's position somewhere conspicuous for a sufficient amount of time and that they were not able to find a qualified American applicant.
Where this gets iffy is that because this is part of a green card sponsorship, this is always an advertisement for a position that is already filled by the H1-B holder, who typically has already been at working in that capacity for at least a year, and who literally is only engaging in this process because they intend to immigrate and become a US permanent resident.
There's literally zero incentive for any company to boot an already productive H1-B holder in favor of some random new hire just because of their nationality. Typically, the way this is justified is that the hypothetical new hire must demonstrate the ability to be as productive as the H1-B holder, including having context on the project. Otherwise, it would just cost the company time and money to fire the employed person and hire/onboard the new one for no benefit to the company whatsoever. It would indeed be doubly bad from a reputation perspective since then foreign talent would definitely avoid applying to a company that just boots people and leaves them out in the cold with an invalid residency status forcing them to move back to their home country in a month's window. The justification that companies can't find the talent in the country boils down to that: where were these so called qualified american candidates a year prior to the PERM application? IF they existed then, the company would certainly have preferred to hire them because H1-B/PERM/green card sponsorship actually costs quite a bit of money to the company.
Now, I may be biased, since I'm a green card holder myself, but the thing with PERM is that the H1-B engagement is a mutual investment which started at least a year prior to PERM coming into the picture in the first place (it's an investment by the company, in terms of finding and onboarding a new person and getting them to be productive, as well as by the employee, who works to build context and become necessary to the company). Is it "fair" that one person ought to have the right to just come in after the fact and enjoy the fruits of other people's investments just because of their nationality, especially considering that this entails a losing party who for all intents and purposes was already a productive member of American society working towards acquiring permanent residency status?