A further corruption: I've read that, even when there is a will to "take a chance" (aka employ and treat as a member of society) people with a criminal record, businesses can face obstacles -- sometimes insurmountable, for a smaller business -- to do so. One particular one: Insurance companies audit for such employees, and either cancel insurance or raise it to unaffordable rates.
America: Land of hypocrisy.
Never been to the States, but shouldn't there be a law against this?
Yes, there are laws and court cases that should change the outcome, but that means a lawsuit.
In other words, US employment frequently comes with a lot of implicit assumptions about your lifestyle.
Edit to add: fortunately random drug tests aren't very common in the tech industry.