Bloomberg Businessweek -- The stories all go something like this: An employee is ordered to take a drug test. They have a medical marijuana prescription for a legitimate illness and tell their employer as much. The employer goes ahead with the test, gets back the positive results, and fires the employee.

Most states have statutes giving companies the right to drug-test the people they hire and to fire them for coming to work under the influence; in the ones that don’t, courts have largely blessed the process. The precedents are murkier when it comes to employees who partake in a state-sanctioned, medically helpful drug in their off hours—and even more so for those who partake recreationally where it’s legal to do so. Until the last few years, courts had largely backed companies that enforce zero-tolerance drug-free workplace policies. But with legalization sweeping the country and stigmas about pot smokers fading, judges and lawmakers are beginning to side with employees.

In July, New Jersey became the 14th state to strengthen workplace protections for medical marijuana users. “The courts are seeing this as something that is very legitimate,” says Jamison Mark, an employment lawyer in New Jersey. “These employees have severe chronic disabilities, and the legislature is smart enough to say, ‘Let’s protect them.’ ” Employers there can no longer refuse to hire people with a medical weed license, and if employees test positive for marijuana, they’ll be given an opportunity to provide a legitimate medical reason for the results.

In the past two years workers who lost jobs because of medical marijuana use won cases in Connecticut, Rhode Island, Arizona, and Delaware, with judges finding employers violated medical marijuana statutes. At the crux of the issue are the drug tests themselves, which aren’t sophisticated enough to determine whether someone got high that morning or last weekend. Most often, employers want to punish drug use on the job. Do they risk keeping someone at work who tests positive and may endanger themselves or others? Or do they fire someone who hasn’t gotten high in days and expose themselves to a lawsuit?

The earliest lawsuits filed on behalf of fired weed smokers started popping up in places like Colorado and California—early adopters of sanctioned pot use—around the late aughts. These cases ran up against federal law, which lists cannabis as a Schedule 1 substance, an illicit drug with “no accepted medical use and high potential for abuse.” In 2015 the Colorado Supreme Court seemed to settle the question of how the courts would handle conflicting state and federal laws when it ruled that Dish Network was within its rights to fire an employee who was treating spinal cord pain related to paraplegia with a weed prescription. The court found he was engaging in “unlawful activity,” a violation of company policy.

A recent Massachusetts case showed one potential way around this precedent. Cristina Barbuto was offered a job with Advantage Sales and Marketing in the Boston area. Before she started, the company asked her to take a drug test. Barbuto, who treats her Crohn’s disease with medical marijuana, told the company the test would come back positive. When it did, the company fired her. Under Massachusetts state law, a company has to seek a “reasonable accommodation” for an employee’s medical condition. In this case, the company didn’t engage in a dialogue with Barbuto to see how it could meet her needs, Barbuto’s lawyers argued. In 2017 the Massachusetts Supreme Court ruled in favor of her right to sue, opening the door for other medical pot users to bring civil claims against their employers. (Advantage later settled.) “It was a groundbreaking case nationally,” says Matthew Fogelman, a Newton-based employment lawyer. Lawyers in New Jersey later won a similar case with the same argument, and the new, more comprehensive legislation soon followed.

In states without explicit protections for employees who toke, lawyers are starting to get creative. Recreational users still have few, if any, workplace protections. “People don’t realize that they can be fired for their recreational use of marijuana” in states where it’s legal, says Danielle Lucido, chief counsel for the Engineers and Scientists union in California. “Unless you have state protective legislation, you’re screwed.” Nevada, which has had medical marijuana laws on the books for two decades and in 2016 voted to legalize recreational use, in June became the first state to pass a law prohibiting employers from refusing to hire applicants who fail drug tests for weed that covers both types of users. New York City passed a similar bill in April.

Whitney Selert, a Nevada-based employment lawyer, says the legislature updated the law to reflect reality: A lot of people are getting high. “The state is just full of growers and dispensaries,” he says. “You can’t swing a dead cat without hitting one in Las Vegas.”

James Reidy, a New Hampshire-based management-side labor lawyer, says employers are beginning to catch up, as well. The tight labor market and the increasing popularity and availability of weed has led some of them to ditch pre-employment drug tests altogether. “They’re looking at the return on investment for testing,” Reidy says. “Do their policies make sense? Do you test for marijuana? Do you care?”