Marissa Mayer, Yahoo CEO. (Laurent Gillieron/AP)

Marissa Mayer, why have you forsaken us?

When the pregnant 37-year-old was named CEO of tech giant Yahoo last year, it was a cause for celebration for many working mothers. Here was a woman who had a marriage, an uber-high-profile job and a baby on the way. Finally, not only was there proof that women could have it all, but there was also a sense that Mayer would understand the difficulties of working mothers in the trenches — and presumably make it better for us.

Then two weeks ago, Mayer decreed that Yahoo employees could no longer work from home. While certainly lots of workers of both sexes telecommute, the reality is that the ability to work from home is seen as the holy grail for working mothers.

Sick kid? Work from home.

Snow day? Work from home.

Spring break and no camp options? Work from home.

And so to many working moms, Mayer’s directive was not a business decision but a betrayal of the sisterhood.

Mayer has been assailed as failing to value employees as people first and as workers second. She has been accused of failing to understand that people who work from home aren’t necessarily slackers. And perhaps most damning, given her position with Yahoo, she has been derided for not understanding how technology makes all things possible.

In a comment posted to Ruth Marcus’s column on this subject, motherintexas recounts how, in her life, she has been on every side of the debate and concludes, “I find it ironic that a woman with a baby (and a few nannies, I’m sure) and the leader of YAHOO of all companies, feels the need to step back in time and order everyone to the big building.”

I understand the outrage, but as someone who has worked from home and who manages people in the workplace, I have to say Mayer got it just right.

Several years ago, during a family crisis, I worked largely from home for a period of several months. I was enormously grateful that The Post allowed me to, and so I worked very hard. The quantity of my work did not suffer. I wrote stories; I edited stories; I responded to e-mails. But the quality of my work suffered. And not because I was stressed by my personal situation. It suffered because I was not in the office.

I couldn’t ask a colleague in the next cubicle what a better word for “cluster” was. I couldn’t suggest a project to my staff and see their eyes roll in a way that indicated I had come up with another clunker of an idea. I couldn’t run into a co-worker in the stairwell, restroom or cafeteria and, as a result of a casual conversation, stumble onto a great project.

I even calculated the diminishment of the quality of my work: Everything I did was about 5 percent worse because I was not collaborating.

To be sure, some jobs don’t require collaboration. Time and energy are saved by cutting down on commuting. The ability to work from home — on occasion, as needed, because the roofer is coming or the kid is sick — is an actual boon to the productivity of most companies.

But John Sullivan, a management professor at San Francisco State University, used my favorite word while appearing on “The PBS NewsHour” with Gwen Ifill to describe what causes the loss of the 5 percent — it’s the lack of serendipity. It is the idea that the whole really is more than the sum of its parts. Mayer has decided that her Yahoo can be better if she brings all its talented people under one roof. And given how the company has been struggling, 5 percent better could make all the difference.

Those of us who hailed Mayer’s ascendancy at Yahoo should be hoping that her “work in the office” mandate and other changes get the company out of its quagmire. A female CEO of a tech giant is a good thing; a successful female CEO of a tech giant is a better thing.

Mayer made an unpopular decision that she clearly thought was in the best interest of her company’s long-term health (and by extension, the long-term employment of her workers). She didn’t betray women by making the right decision for her company. Being able to realize that is what real sisterhood is about.

Grant is the editor of KidsPost.