The news that California public school teachers must pay for their own substitutes if they’re out with a major illness went viral — picked up by People magazine, “NBC Nightly News” with Lester Holt, the BBC and other media outlets worldwide.

The story, after all, was a real head scratcher.

A second-grade teacher at San Francisco’s Glen Park Elementary had to take a medical leave for cancer treatments — and the San Francisco Unified School District required her to pay for her own substitute, prompting distraught parents at the school to set up a GoFundMe drive and kids to host bake sales on her behalf.

The school district blamed a 1976 California law stating public school teachers can take up to 100 days of sick leave but can be docked the cost of their replacement. But it doesn’t have to be that way. Like so much of government bureaucracy, the district’s policy defied common sense.

“It’s so crazy and inflammatory — like this has to be wrong, but it’s not!” said Richard Shapiro, a physics teacher at Lowell High. “It’s absolutely true.”

Shapiro can vouch for the insanity because he lived it. The beloved teacher, a member of the Lowell faculty since 1990, missed about six weeks of school in fall 2015 to have a tumor on his liver removed. But the tumor came back a year later, and Shapiro needed a longer leave, eventually undergoing a liver transplant in May 2017.

At a faculty meeting in fall 2016, the Lowell principal told the Shapiro’s colleagues about his predicament and asked them to donate their sick days so Shapiro could continue to draw a full salary. The staff gave a total of about 200 days, and Shapiro took his leave feeling grateful for his colleagues’ generosity and relieved he’d get whole paychecks.

“That made me feel really great,” he recalled. “People need to be reminded that they’re appreciated.”

But the paychecks during his leave were much lower than expected. In fact, they were only about half of what he thought he was due.

The problem?

The San Francisco Unified School District interprets that 1976 state law about as harshly as can be. It refuses to allow teachers like Shapiro to use donated sick days in the district’s catastrophic sick leave bank until they take 100 days of extended sick leave, during which they must pay for their own substitute, which is currently $203 per day.

Laura Dudnick, a spokeswoman for the school district, said the district is bound by the California education code that requires teachers to pay for their own subs for 100 days before using donated sick days from their colleagues.

But the education code doesn’t say that, and several school districts around California including San Diego, Palo Alto, Albany and Novato allow teachers to use their colleagues’ donated days first, which is spelled out in their teacher contracts and which I reviewed. After all, it costs the school districts nothing because it’s merely shifting paid sick time among teachers.

“The district held firm that it’s state law, which it’s not,” said Shapiro, 69, adding his colleagues’ days weren’t returned to them and they were simply held in the leave bank for all district teachers even if that wasn’t the donors’ intention. “They were cheated.”

The district and union maintain a catastrophic sick leave bank of donated days, which can be tapped by teachers with very long-term illnesses who’ve already been out for 100 days while paying for a substitute. The Lowell donations remain in the bank.

Shapiro, who’s at the top of the pay scale and bought a home in the city decades ago, called it a “financial inconvenience” and said he had to dip into savings to get through the leave. A new teacher in San Francisco who goes on leave for cancer treatments would have it far worse — and would actually make nothing under the district’s rules.

A new, fully credentialed teacher in San Francisco will start the next school year in August at $63,458 a year, or $1,220 a week. Covering his or her own substitute at the daily rate of $203 would eat up $1,015 of that paycheck. After taxes, the teacher would earn nothing during a stressful medical leave. Need to pay rent and buy food? Not the district’s problem.

“We’re not aware of any employers, public or private, that pay employees their full salary while on extended sick leave,” Dudnick said, adding that most teachers have worked in the district a decade or more and would bring home a higher percentage of their pay if out on extended sick leave.

The contract guarantees that teachers out on maternity leave will receive a minimum of $150 a day — yes, new moms have to pay for their subs too — but there’s no guaranteed minimum for teachers out with a debilitating illness.

Dennis Kelly, the former president of the San Francisco teachers union, said the 1976 state law was meant as a benefit to teachers who don’t pay into the state’s disability insurance program and can’t draw from it if they get sick. Teachers in San Francisco aren’t eligible to participate in the state disability program.

Back then, Kelly said, substitutes were paid far less compared with full-time teachers so educators still received most of their paycheck if they faced cancer or some other major illness.

But the math doesn’t work out that way anymore — not even close. Substitutes now rightly make far more than they used to, and some teachers’ salaries continue to be far lower than what’s fair — especially in one of the most expensive cities in the world.

The 1976 state law also says any school district is free to make “any reasonable rule for the regulation of accident or sick leave ... without loss of salary” for teachers. That means the law set a bare minimum, and districts are free to be more generous.

Kelly said it’s “eminently possible” under state law for districts to allow teachers to use donated days first.

“It’s a way for employees to take care of one another,” he said. “It really is a gesture of kindness from other people.”

Susan Solomon, the current president of the teachers union, said she intends to raise the matter when bargaining begins for the next contract in next spring. She’d like to see teachers allowed to use donated days first and sick teachers be guaranteed a minimum salary of $150 a day like those on maternity leave.

She said the viral story about the Glen Park teacher prompted a phone conversation between her, union officials from other districts around the state and Gov. Gavin Newsom’s representatives to discuss potential changes to the state law.

“They asked smart questions in terms of legislation,” she said, adding it’s unlikely anything would be proposed until next year due to the legislative calendar. “They definitely took notice.”

Shapiro said that the sick leave fiasco is easily rectified, and the larger issue for the San Francisco school district is “learning how to respect teachers.”

“They have a long, long way to go with that,” he said.

Dudnick said teachers can buy long-term disability insurance through third parties — and pointed out that San Francisco teachers get lifetime health benefits after working in the district 20 consecutive years.

Still, there should be protections for younger teachers who get sick and who are essential to keep on board in this city with exorbitant rents and high teacher turnover.

As for Shapiro, he’ll be 70 in October but has no plans to retire. He’s now healthy — and missed only one day of school since returning from his leave in fall 2017.

“I’m taking it year to year, but I’m having a great time,” he said. “I think I still do a great job.”

San Francisco Chronicle columnist Heather Knight appears Sundays and Tuesdays. Email: hknight@sfchronicle.com Twitter: @hknightsf