The California Supreme Court says state law requires Apple to pay retail store employees for the time they spend waiting for bag searches at the end of a shift, the Los Angeles Times reports.

“We conclude that plaintiffs’ time spent on Apple’s premises waiting for, and undergoing, mandatory exit searches of bags, packages, or personal Apple technology devices, such as iPhones, voluntarily brought to work purely for personal convenience is compensable as ‘hours worked,’” Chief Justice Tani Cantil-Sakauye wrote in the court’s decision.

Apple’s policy requires retail store workers to submit to searches of their personal bags after clocking out but before leaving the store. The policy requires the manager conducting the search to “ask the employee to remove any type of item that Apple may sell” and verify serial numbers of an employee’s “personal technology.” The employees said that on busy days, they might end up waiting close to 45 minutes for a manager or security officer to be available to conduct the search, per the company rule. Apple has 52 retail stores in California.

Apple argued that store workers could choose not to bring bags or personal Apple devices — which it characterized as “optional” — to work and avoid the searches. The company argued that this policy benefited the employees being searched, which the court said was “far-fetched.”

“The irony and inconsistency of Apple’s argument must be noted. Its characterization of the iPhone as unnecessary for its own employees is directly at odds with its description of the iPhone as an ‘integrated and integral’ part of the lives of everyone else,” the court wrote.

A group of workers filed a class action lawsuit against the company, and the US Ninth Circuit Court of Appeals asked the state Supreme Court to determine whether California state law required the employees to be compensated for this waiting time.

The California Supreme Court decision is retroactive, and the case now returns to the Ninth Circuit for the judges to apply the interpretation, the LA Times explains. Apple did not respond to an email from The Verge seeking comment.