For three glorious seasons, The Office kept its characters in a state of exquisite misery. Professional dreams were snuffed out. Grand romantic gestures were rebuffed. Bats wreaked havoc on Dunder Mifflin. The place might as well have been haunted.

The black hole at the core of Scranton’s finest paper company was the broken relationship between Jim Halpert and Pam Beesly. As they ping-ponged from being friends to spurned lovers to really awkward acquaintances, the show offered up wincing camera glances and teary confrontations as often as it did laughs. At the end of Season 3, Jim finally asks Pam out on a date, and they live more or less happily ever after for the next several seasons of the show. Other characters also find romantic and professional happiness over time—even Michael Scott eventually finds the girl of his dreams. By the end of the series, the gang is almost literally singing kumbaya in the workspace that was once their 9-to-5 hell.

But the cringe-inducing cynicism of early Office remains a masochistic joy in its own way, perhaps easier to stomach now since all the characters’ happy endings are assured. As I watched Pam ducking out for a regular cry or Michael verbally abusing Toby for the fifth time, though, I wondered: Which character is the most miserable of these generally unhappy souls?

To find out, I developed a highly scientific formula to measure everyone’s happiest and unhappiest moments over time across the first three seasons. Characters earned points if they performed any of the measured activities once or more in a given episode. The criteria are as follows.

Happy Activities

Laughing (1 point)—Common activity of Michael Scott and Kevin Malone; anathema to Angela Martin.

Camaraderie (2 points)—Includes high jinks like the Office Olympics, high fives, hugs, and flirting at the reception desk.

Dancing (3 points)—Doesn’t have to be as intense as Michael’s booze cruise moves to qualify.

Making Out (4 points)—Usually makes people very happy, but no points will be awarded for kisses that were coerced, like Michael’s kissing of Oscar in “Gay Witch Hunt” or Jan’s attempt to force Michael into sex in “Cocktails.”

Expressions of Love (5 points)—This includes not just Jim-Pam romantic theatrics, but also heartwarming moments when the Office crew shows they deeply care for one another, like when Michael attends Pam’s art show or when the Dunder Mifflin team cheers Michael on during the Dundies.

Unhappy Activities

Rolling Eyes (1 point)—The basic, passive-aggressive unit of dissatisfaction in any office environment.

Yelling (2 points)—Stanley is The Office’s scariest yeller.

Crying (3 points)—Common activity of Michael Scott, Dwight Schrute, and Pam Beesly.

Violence (4 points)—This mostly incorporates physical violence, like when Roy tries to attack Jim, but can also include psychological violence, like when a flasher exposes himself to Phyllis in the Dunder Mifflin parking lot, or when Michael locks Kevin in a room with a smelly carpet.

Professional/Relationship Failures (5 points)—When somebody gets dumped, gets fired, gets left behind on Beach Day (poor Toby), or admits that their life is largely devoid of meaning, it’s not a great look.

After calculating a Happiness Score and an Unhappiness Score, I divided each character’s Unhappiness Score by the total to get their Unhappiness Ratio. So here’s the entire Office cast, presented from happiest to most miserable.

Kevin Malone

Happiness Score: 38

Unhappiness Score: 11

Happiest Moment: Playing Phyllis’s wedding

Unhappiest Moment: When Michael locks him in his office with the shit-stained carpet

Kevin is a man of simple pleasures. He likes stuffing large numbers of jelly beans in his mouth, gambling, and singing songs by the Police. He can often be found in an office confessional or background shot laughing in an adorable, high-pitched giggle. While others at Dunder Mifflin search for love or professional fulfillment, Kevin is content to joke around with Oscar and participate in whatever time-wasting stunt Jim puts on offer. He’s a team player, a low-stress personality (even when he might have skin cancer!), and easily the happiest person on The Office.

Phyllis Vance

Happiness Score: 58

Unhappiness Score: 25

Happiest Moment: Marrying Bob Vance

Unhappiest Moment: Being trapped on the Party Planning Committee

Phyllis loves to dance, a signal that she’s able to find joy in even the bleakest office scenarios. At nearly every Dunder Mifflin party, she can be seen in at least one background shot throwing down. She accepts Michael’s wide-ranging insults with a quiet dignity, rarely rolling her eyes or tearing up. She doesn’t yell. Her only enemy in the office is Angela, who is also, tragically, her closest colleague on the Party Planning Committee. But the real reason Phyllis stands out is because she is the only person in the entire office to maintain a stable, healthy relationship throughout most of the first three seasons. Shout-out to Bob Vance (Vance Refrigeration), who helped Phyllis become one of Dunder Mifflin’s happiest employees.

Darryl Philbin

Happiness Score: 19

Unhappiness Score: 9

Happiest Moment: Teaching Michael fake black slang

Unhappiest Moment: Breaking his ankle when Michael pulled a ladder out from under him

As the foreman of the Dunder Mifflin warehouse, Darryl is Michael’s polar opposite when it comes to leadership style. He’s levelheaded, rarely emotional, and actually capable of driving a forklift. Mocking Michael for inadvertently wearing women’s clothing, earning a paltry salary, and generally being a wuss are Darryl’s great joys in life. The only thing that makes him angry is office workers—OK, one specific office worker—causing life-threatening mayhem in his warehouse. Still, there’s a Zen to Darryl’s personality that makes him one of the most amicable office employees. As a wise African American once said, “Dinkin flicka.”

Creed Bratton

Happiness Score: 20

Unhappiness Score: 13

Happiest Moment: Reminiscing on the free-love sexual expression of the 1960s

Unhappiest Moment: Being tackled by Dwight after catching a football

To ask whether Creed is happy or unhappy is to ask whether a cockroach is happy or unhappy. The creature’s life is only about survival. In most Creed scenes, he is offering a strange factoid about his past or executing a low-level scam on his officemates. Who knows whether these exploits bring him joy? What we do know is that he’s also a willing participant in camaraderie-building exercises like the Office Olympics, and he once got really upset when Jim didn’t believe that Dwight had been decapitated.

Jim Halpert

Happiness Score: 131

Unhappiness Score: 99

Happiest Moment: Asking Pam out on a date

Unhappiest Moment: Getting shot down by Pam twice in one night

As Dunder Mifflin’s resident prankster, Jim spends more time than anybody else finding ways to wring enjoyment out of his boring life as a literal paper-pusher. Hardly an episode goes by where Jim isn’t devising fun ways to waste time, often enlisting his officemates (especially Pam) to be part of his mischief. His camaraderie score is off the charts. But Jim also harbors a crush on Pam in secret for years, leading to plenty of episodes where his office shenanigans ultimately can’t distract him from his deep-seated heartache. He’s spurned when he confesses his love to her, then has to figure out a way to awkwardly coexist with her while simultaneously dating (read: stringing along) another woman. His life is a confused, emotionally stunted mess, but dude’s got jokes. So he doesn’t quite slip into the tier of The Office’s most miserable characters.

Pam Beesly

Happiness Score: 141

Unhappiness Score: 110

Happiest Moment: Finding self-actualization by walking on blazing hot coals

Unhappiest Moment: Witnessing the fight between Jim and Roy

In the very first episode of The Office, Pam admits, “I don’t think it’s any little girl’s dream to be a receptionist.” She also cries in Michael’s office after he tricks her into believing she has been fired. Going from this rocky beginning to her troubled relationships with both Jim and Roy, it’s easy to imagine that Pam would end up being the least happy character on the show. Day to day, though, Pam is often having a good time. She’s constantly laughing at Jim’s pranks and shows a high level of compassion for many of her officemates, boosting her camaraderie score. And as The Office’s most cynical stretch draws to a close, Pam becomes an avid practitioner of self-care, using bracing honesty to both reconnect with Jim and assert her independence. Good going, Pammy (but don’t call her Pammy).

Dwight Schrute

Happiness Score: 109

Unhappiness Score: 88

Happiest Moment: Having Michael rescue him from Staples

Unhappiest Moment: His failed coup against Michael

Dwight loves selling paper, loves his boss, and loves Angela. He could be a consistently happy person at Dunder Mifflin, if not for the crippling megalomania that convinces him to try to usurp Michael and consistently fall for Jim’s pranks. Dwight is so sure of himself that he’s constantly stumbling into failure with an arrogant stride. He did have at least one blissfully happy episode separated from his own ego, though, when he was concussed after an accident in the parking lot.

Meredith Palmer

Happiness Score: 28

Unhappiness Score: 25

Happiest Moment: Hooking up with the captain on the booze cruise

Unhappiest Moment: Having Dwight trap her head in a bag with a bat

Meredith is a single mother nursing an alcohol addiction and saddled with the most monstrous minivan east of the Mississippi. Things are not great. But even under her poor circumstances, Meredith manages to find more bad luck. Is there a fate worse than having your head trapped in a plastic bag with a live bat while a man holding you in his clutches refuses to let you escape? Maybe getting hit with a car would be worse, but that doesn’t happen to her until later in the series. It’s a testament to Meredith’s resilient spirit (and Dunder Mifflin’s open-bar office parties) that she’s not miserable more often.

Michael Scott

Happiness Score: 170

Unhappiness Score: 153

Happiest Moment: Being feted at the Dundies

Unhappiest Moment: Getting dumped by Carol Stills

Michael Scott contains multitudes—he laughs, cries, screams, and dances with shocking regularity. He’s a hopeless romantic (not in the good way), but still winds up with two dates during “Casino Night.” His life, as a middle-aged office manager whose most important human relationships are with a group of indifferent-to-deeply-offended employees, could easily drift into aching despair. But those same oft-disgruntled workers bring Michael some of his happiest memories. Amid the relentless cynicism of the early Office years, the most purely joyful moment is toward the end of “The Dundies,” when hecklers at Chili’s are mocking the awards show and Pam rallies the Dunder Mifflin staff to cheer Michael on. He’s a misfit, but he’s their misfit.

Oscar Martinez

Happiness Score: 21

Unhappiness Score: 19

Happiest Moment: Getting a paid vacation in exchange for not suing the company for sexual harassment

Unhappiest Moment: Being sexually harassed by Michael

Oscar typically lets the frustrations of Dunder Mifflin roll off him, content to play paper football with Kevin and mostly ignore Angela’s eye-rolls. But he’s pushed to his limit in “Gay Witch Hunt,” the episode in which Michael outs him as gay. Oscar gives Michael a vicious dressing down, calling him ignorant and small. Then out of pity or love or a desire to avoid being laid off during downsizing, he quickly apologizes and the two share an agonizingly labored kiss. It would almost be sweet if it weren’t so awkward and inappropriate. Oscar’s happiness bottoms out in this episode, but then he’s given several months of paid vacation by the company to avoid a lawsuit, giving him the longest uninterrupted run of happiness of any character in Office history.

Stanley Hudson

Happiness Score: 33

Unhappiness Score: 35

Happiest Moment: Pretzel Day

Unhappiest Moment: When he thinks Ryan is flirting with his eighth-grade daughter

In “Office Olympics,” when Jim asks Stanley whether he wants play a game, Stanley replies, “Yeah, I got a game. It’s called work hard so my kids can go to college.” Stanley has no time for your office romances and pranks and pointless conference room meetings. All he cares about are his crossword puzzles and his annual soft pretzel. And yet those big, baleful eyes of his can’t help but roll whenever Michael does something embarrassing. Stanley isn’t exactly happy, but he’s also completely fine with being unhappy and doesn’t want you to even bother trying to cheer him up, because you’re not his friend.

Kelly Kapoor

Happiness Score: 33

Unhappiness Score: 45

Happiest Moment: Hooking up with Ryan the day before Valentine’s Day

Unhappiest Moment: Most other interactions with Ryan

I have a theory that sometime early in Season 2, Kelly Kapoor staged a Freaky Friday–style body switch with one of her younger sisters (Rupa, Neepa, and Tiffany) and remained in the mind-set of a teenage girl for the rest of the series. How else to explain how the buttoned-up professional from Season 1 became the Ryan-crazy ball of misplaced exuberance by the end of Season 3? Kelly has her heart broken time and time again by Ryan, her equally immature soul mate. And though her completely one-sided BFF relationship with Jim gives her a person to talk at, it doesn’t bring her happiness. Poor Kelly deserved better.

Ryan Howard

Happiness Score: 30

Unhappiness Score: 42

Happiest Moment: Leaving Scranton and breaking up with Kelly

Unhappiest Moment: Becoming “the fire guy”

Ryan has a girlfriend and a boss who are madly in love with him, yet he still manages to be one of Dunder Mifflin’s least happy employees. He rarely laughs. He doesn’t dance. He is incapable of articulating his emotions. And most of his attempts to become a good salesman end in disaster—he’s annoyed by Michael, hazed by Dwight, and mocked by Stanley. Ultimately Ryan’s problem is that he refuses to commit to anything, whether it’s Kelly or the job where he started out as a temp. But he improbably lands an executive position at Dunder Mifflin (and dumps Kelly) in the last moments of Season 3, proving that disaffected bros will never stop failing upward.

Toby Flenderson

Happiness Score: 18

Unhappiness Score: 30

Happiest Moment: Kissing his date at Phyllis’s wedding and yelling, “Toby! Yeah!”

Unhappiest Moment: Getting left at the office on Beach Day

Jan Levinson

Happiness Score: 19

Unhappiness Score: 34

Happiest Moment: Closing a deal with Michael at Chili’s and making out in the parking lot

Unhappiest Moment: Getting fired from Dunder Mifflin

When Jan laughs, it’s ruefully. When she makes out, it’s at the least appropriate time. When she expresses love, Michael naturally recoils. Even in her happiest moments, Jan cannot escape the high-strung anxieties that make her one of The Office’s most miserable characters. Though she begins the series as a stern but competent boss, a poorly conceived dalliance with Michael Scott unravels her; by the end of Season 3 she’s daydreaming about a domestic life with a man who has already admitted she makes him unhappy. These two are a disaster in the best possible way.

Angela Martin

Happiness Score: 30

Unhappiness Score: 58

Happiest Moment: Vicariously reliving the Roy-Jim-Dwight fight through others

Unhappiest Moment: Losing the war of the Christmas parties to Pam and Karen

After watching her closely over the course of these three seasons, I’ve decided that Angela actually enjoys being unhappy. She likes rolling her eyes at anyone within her line of sight. She likes quietly scolding camaraderie-building office high jinks. She likes calling various colors that Phyllis favors “whorish.” Angela is a hater to the bone, poised and precise with her vindictiveness. She would take it as a badge of honor to be considered one of the least happy characters on The Office and smirk at the notion that anyone could actually enjoy their time at Dunder Mifflin. The only thing that betrays her stone-cold indifference to the feelings of others is her deep affection for Dwight.

Andy Bernard

Happiness Score: 13

Unhappiness Score: 33

Happiest Moment: Getting wasted at the Stamford branch with Jim and sleeping on the floor

Unhappiest Moment: Being banished to anger management classes

Andy is simultaneously the most upbeat, agreeable person on The Office and the angriest, most despised person on The Office. Dwight shuns him. Jim finds him more annoying than Dwight. Michael serves him a level of vitriol usually reserved for only Toby. He’s rejected by Pam, eclipsed professionally by Jim, and appears to have no friends inside the office or out. His chipper personality seems to be hiding a roiling anger, which erupts so violently after one harmless prank that he punches a hole in the wall. Andy’s personality eventually calibrates to less of an extreme. He finds a romantic partner in Erin. He even becomes regional manager. But when he’s introduced to The Office as an arrogant, angry, a cappella–obsessed goof, he is the show’s least happy character.