There are really two aspects to this issue. One of them is the one you described above: if companies are willing to pay money for the work these people do, they can't be that stupid. The other aspect is the one that FormerLurker has been pushing: companies might employ these people only out of political correctness--to keep the Leftist diversity police at bay.
As you may have already recognized, both of these lines of reasoning lead to the same conclusion: let the companies decide for themselves rationally, rather than have the government--or the Leftist trendsetters--tell them what to do.
As for the possibility of Communist spies infiltrating the country in the guise of software developers, I think the threat may very well be real. Any sort of visa application from a national of a Communist country should be evaluated with a healthy dose of suspicion, and with a preference to err on the side of caution. If that means no Chinese developers at all, well we're sorry, just shut up and take it.
Actually, what I'm saying is that this influx of cheap labor is motivated by greed. Those companies that are laying off thousands of US engineers and replacing them with cheap foreign help display absolutely no concern over the long term ramifications of such a policy. In fact, the reason the economy is in the gutter right now is primarily due to the enormous number of engineers out of work. A snowball effect appears to be taking place, and it doesn't appear to be stopping.