The California Supreme Court has made a decision in a class-action lawsuit against Apple that dates back to 2013. According to today’s decision, Apple is required to pay its retail workers for the time it takes for their bags to be searched after their shifts.

Apple retail workers filed the class-action suit against Apple in 2013, saying that they were required to submit to search before leaving for the day, including searches of their bags, purses, backpacks, brief cases, and personal Apple devices.

For instance, an Apple retail worker’s shift could be over, but they are required to wait for a manager or security officer to perform the search. Employees said they could be forced to wait for as long as 45 minutes, and would not be paid for any of that time.

A California judge dismissed the class-action suit in 2015, but that decision was appealed. The United States Ninth Circuit Court of Appeals then asked the California Supreme Court to clarify the law. Today, Bloomberg Law reports that the California Supreme Court has ruled in favor of the workers: Apple violated state law when it didn’t pay for the time spent waiting on mandatory searches at the end of shifts.

Under California law, workers are required to be paid of all hours worked. Chief Justice Tani Cantil-Sakauye explained that Apple employees “are clearly under Apple’s control while awaiting, and during, the exit searches.”

The court also slammed Apple for its argument that employees could simply leave their personal bags and iPhones at home:

“Under the circumstances of this case and the realities of ordinary, 21st century life, we find far-fetched and untenable Apple’s claim that its bag-search policy can be justified as providing a benefit to its employees,” the court said.

During the lawsuit, it was revealed that Tim Cook was largely unaware of the policy of checking employee bags. When two employees complained directly to Cook about the issue, he forwarded the email to his HR executives, asking “Is this true?”

The ruling is retroactive, which means Apple could be on the hook for millions of dollars in unpaid employee wages. The case will now return to the Ninth Circuit, where federal judges will apply the interpretation of state law.