Last summer, after the U.S. Supreme Court ruled public sector unions couldn’t compel fees from nonunion workers, the talk was that organized labor had been hit hard, was facing a mass exodus, and was playing defense even in pro-labor California.

Talk about a comeback.

This week, as state lawmakers wrap up for the year, labor is celebrating a banner year in Sacramento: New restrictions on California charter schools at the behest of the teachers unions. A bill to allow unionization for child care workers. And on Wednesday, the signing of AB 5, a nationally watched measure converting 1 million California freelancers into employees while granting them a suite of protections along with the right to join unions. The bill takes effect Jan. 1.

The turnaround is no accident. After the U.S. Supreme Court’s dues-gutting decision in the case of Janus v. AFSCME, labor went into political overdrive last year in California, pushing a series of bills through the Legislature that, among other things, forced state and local governments to give unions access to newly hired public employees.

That helped shore up membership — and dues — in the influential unions that represent teachers and government workers. But experts say labor still has its work cut out, even with the passage of AB 5, touted as a path to more job security for gig economy workers.

While the bill is at once potentially transformative, it is also filled with complications and pitfalls, said Stanford law professor William Gould, a former National Labor Relations Board chairman. Uber, Lyft and DoorDash have put $90 million toward seeking an end run around it. In his signing statement, Newsom alluded cryptically to what may be an Achilles’ heel in the legislation: the fact that, however California regards its 200,000-plus gig workers, the federal government still categorizes them as freelancers.

And it remains to be seen whether unions, even in California, can turn a paper victory into a meaningful labor movement that results in more private-sector members.

Union membership has fallen to a historic low as a share of the state’s workforce. According to the Bureau of Labor Statistics, the unionization rate here is 50% in the public sector and just 8.3% in the private sector.

“It depends on the energy that the unions put into organizing the unorganized,” Gould said in an interview. “From the ‘40s to the ‘60s, the unions were spending approximately 30% of their budget on organizing. Today, it’s about 3%. So it depends on the ability of labor to take AB 5 to the next step, which is to organize and create an effective mechanism.”

Gould uses the farm workers movement as a cautionary tale. Though California passed the Agricultural Labor Relations Act in 1975, making it the first state to establish collective bargaining rights for farmworkers, most fields today are not unionized.

“That whole movement now and the law supporting it is completely moribund. For all intensive purposes, it doesn’t exist,” Gould said. “There is no union organizing in agricultural even though more than 95% of the fields are nonunion. The lessons of the past, of which the Agricultural Labor Relations Act and the farm labor movement is a prime example, is that paper mechanisms don’t necessarily translate into real gains.”

Looking back, the tide turned for labor almost immediately after Janus came down. Last year was a gubernatorial year, so the teachers union endorsed then-candidate Gavin Newsom over Antonio Villaraigosa, the former mayor of Los Angeles who was backed by charter school boosters. In the Legislature, Democrats made record gains.

Meanwhile, perhaps by serendipity, the California Supreme Court gave them another judicial shot of momentum. Ruling in an outsourcing lawsuit brought by a same-day courier service, Dynamex Operations West, Inc. v Superior Court of Los Angeles, the state high court made it more difficult for businesses to classify workers as independent contractors, thereby saving on payroll.

The ruling established a three-part test, or ABC test, for certifying freelancers with the highest hurdle that the work performed must be outside the core of the company’s business. The Legislature could have immediately codified it, but Senate President Pro Tem Toni Atkins told members she wanted to allow a robust debate.

What followed was a benchmark year for labor unions that could significantly expand collective bargaining in the private sector, which has been on the decline for decades.

Labor leaders and their political allies believe that with an increasing wealth gap and automation, burgeoning campaigns such as the Fight for $15Restaurant Opportunities Centers (ROC) UnitedGig Workers Rising and Mobile Workers Alliance are pivotal for the future of workers.

“For so long, we had focused so much on public sector unions — and we’re going to continue to defend and protect those — but we’re also going to look at the private sector,” said Assemblywoman Lorena Gonzalez, AB 5’s author. “We see income inequality growing at staggering paces and a lot of that is the narrowing number of unions in the private sector. There was a desire to push back and go hard.”

Steve Smith, a spokesman for the California Labor Federation, an umbrella organization representing 2 million members, said labor has always advocated for workers regardless of whether they’re members. In California, unions helped pass paid family leave and the $15 minimum wage, making the state the first to offer such benefits.

Similarly, workers ranging from gig workers, truckers, janitors and health aides, all stand to benefit from AB 5. Labor leaders note that rideshare drivers are scrambling to make ends meet, jumping from one app to another to cobble enough earnings, or sleeping in their vehicles as a an ever bigger slice of their fares goes to Lyft or Uber.

In shifting workers to employee status, companies would have to offer basic worker protections such as guaranteed minimum wage, overtime pay, contributions to Social Security and Medicare, unemployment and disability insurance as well as workers’ compensation, sick leave and family leave.

“The protection they’re going to get under AB 5 is going to be a vast improvement,” said Bob Schoonover, president of the Service Employees International Union Local 721, which represents 95,000 public employee workers in Southern California. Among those protections: the right for cities and the state to sue over violations, a strong tool for enforcement.

But there also are asterisks, among them a state-federal schism that the governor and some labor leaders say will require additional legislation. In their view, because federal labor laws treat gig workers as freelancers, there’s a need — and an opportunity — for the state to craft something new, perhaps modeled after the Agricultural Labor Relations Act, to ensure the state’s new rights for gig workers won’t be preempted.

“The attorneys have told us it would take something else in California for them to be able to organize,” Schoonover said.

Meanwhile, companies from tech to trucking vow to continue their resistance. On the same day lawmakers passed AB 5, Lyft and Uber said they would fight the court’s year-old Dynamex decision at the ballot box in seeking an end run around AB 5. Uber’s chief legal council Tony West said the company believes it can pass the stricter standard for contract workers, known as the ABC test, because drivers are not core to its business.

“Under that three-part test, arguably the highest bar is that a company must prove that contractors are doing work ‘outside the usual course’ of its business,” West told reporters. “Several previous rulings have found that drivers’ work is outside the usual course of Uber’s business, which is serving as a technology platform for several different types of digital marketplaces.”

Technological workarounds could also undermine unions.

“They’re fighting a 20th Century battle in the 21st Century,” said GOP political consultant Mike Madrid. “What labor is trying to do is create an organizable workforce in an era when all of human activity is moving into the opposite direction.”

Businesses, Madrid said, will simply look to automation, including driverless cars, to get around workers and laws such as AB 5.

Republican lawmakers also criticize AB 5 for netting workers they consider to be legitimate independent contractors such as foresters, health care professionals, physical therapists, interpreters, translators, single-truck operators, and even musicians and nonprofits.

But GOP members have been marginalized in the Trump resistance state. In a particularly heated exchange in the Senate on the final day of session, Sen. Jeff Stone, a Republican from Temecula, accused his more liberal colleagues of thwarting “the will of the voters in the name of big labor union bosses” and decried union “control” of the body.

That prompted a reprimand of incivility, which in turn led to cries of bullying, lecturing and personal attacks. Deliberations were temporarily put on hold to let things cool things down.

Organized labor didn’t get 100% of this year’s wish list: A bill that would have let striking workers collect unemployment benefits and a proposed ballot measure to restrict public university’s use of independent contractors both failed.

But 2019 does represent a legislative high-water mark. Besides AB 5, unions could also see their ranks swell with a bill, now on the governor’s desk, that would give 40,000 childcare workers who serve parents that receive state subsidies the right to collectively bargain. This is the tenth time labor activists have introduced the proposal, but with “Governor Dad,” they’re optimistic it may get signed.

Other high priority union wins included restrictions on the expansion of public charter schools (where teachers are typically non-union) and limitations on mandatory arbitration as a condition of employment (which could make it easier for workers to file class action lawsuits).

So far, Californians are supportive. A survey out this week by Emerson Polling found 50% support giving gig workers employee status, compared to 24% opposed and 27% undecided.

And workers are hopeful. Oakland resident Luke Rivera, 39, who drives about 30 hours a week for Uber, said aspires to be like his uncle, whose work as a long-haul truck driver represented by the Teamsters supported a home and a family.

“When he passed away 5 years ago, he had a million dollars saved up from driving a truck,” said Rivera. “We want the opportunity to work our butts off and say, ‘God dang it, I was able to save a million dollars in my lifetime.’”