There’s an episode in the first season of The Office in which Michael Scott, the tactless boss, is asking his female employees to serve as cheerleaders for an upcoming company basketball game. When the heavyset Phyllis says she’ll do it, Michael reflexively says, “Oh yuck, that’s worse than you playing.” He then tries to rescue the crack with, “because we need you as an alternate.”

According to a new study published in the journal Psychology and Aging, this type of humor is exactly the kind you should never deploy around the elderly.

Jennifer Stanley, a psychology professor at the University of Akron, had 30 young adults, 22 middle-aged people, and 29 senior citizens watch a variety of different sitcom clips, including the above segment from The Office. The subjects rated how socially appropriate and how funny they found each clip. Stanley also used facial electromyography to determine how much the clips caused their smile muscles to move.

And for the record, “to be coded as a smile, there had to be an upturn of the corners of the lips plus a wrinkling of the crow’s feet at the corners of the eyes, or a pushing up of the cheeks."

What the authors found was that older adults were much less likely to be fans of the aggressive style of humor—laughing at the expense of others—that’s so often used by Michael Scott. The 64-to-84-year-olds found The Office clip about 23 percent less funny than the middle-aged people did, and about 19 percent less funny than the 17-to-21-year-olds did.

Young adults were also more likely to smirk at the clips that showed self-deprecating humor, as exemplified in an episode of Curb Your Enthusiasm in which Larry pumps his waiter for information about how much his friend left as a tip.

The older participants, meanwhile, liked affiliative humor—the kind of jokes that bring people together through a funny or awkward situation. Stanley says a Golden Girls clip in which the women try to buy condoms and suffer an embarrassing price check is a good example.

Humor relies on the psychological idea of the benign violation: Situations that are mostly wrong but still a little bit right. If something is too banal, it won’t be funny. Go too far, though, and you’ve just offended the person. Michael Scott’s offensive quips can apparently be a little too much for older viewers.

So why doesn’t grandma find that aggressive style of humor funny, young man? One explanation might be that the jokes in sitcoms have changed over time, and today’s older people are just accustomed to a gentler kind of wit. People also might have a greater emotional connection to a show from their own generation—Golden Girls is a much earlier show than either The Office or Curb Your Enthusiasm.

It’s also possible that the study authors chose an unusual episode of The Office to represent aggressive humor. Connoisseurs of the show have suggested that in its first season, it didn’t yet have the time to explore the sadness of Michael’s character—how his petty tyranny was motivated by a deep desire to be liked. Though fat-shaming is always disturbing, the joke in that exchange wasn’t on Phyllis; it was on Michael.

In a review of that episode, The Awl, which has a youngish demographic, also said Michael’s reaction to Phyllis contains “a nastiness ... the source of which we just don’t understand yet.” An earlier study showed that older adults, when watching the British version of The Office, were worse at picking up on the times when the Scott-like character, David Brent, committed a social gaffe.

Stanley suspects a big reason for the generation gap in humor is that as we age, we experience a variety of physical and emotional setbacks—declining cognitive faculties, friends who pass away—and the affiliative style of humor helps us deal with these losses.

“Other work has shown that the importance of having people close by you when you experience the physical and emotional loss of aging,” she told me. “Maybe affiliative humor is more helpful for promoting that type of experience.”

It’s fall, which means the long march of the holiday season is nearly upon us. Stanley’s study is one worth keeping in mind as we weigh which comments to bury deep within our psyches at the Thanksgiving table. To keep peace with the elders, it suggests, act a little more like Blanche Devereaux and a little less like the boorish branch manager of Dunder Mifflin.