Image copyright Getty Images Image caption Humour can bring offices together

Have you heard the joke about the humourless office worker who went for a promotion? He didn't get it.

In workplaces around the world a bit of humour can go a long way towards making it a more enjoyable place to spend eight or so hours a day.

But for every genuinely funny employee or boss, there are others whose unfunny or inappropriate jokes make colleagues wince.

So treading carefully, how exactly does humour help both improve a workplace and the standing of the person who is good at it?

When Steve Carlisle, president of General Motors of Canada, walks around the firm's Ontario headquarters he shares jokes, and uses humour to bond with his staff.

"I believe having a sense of humour is part of the leadership package," Mr Carlisle says. "It can help people feel more relaxed, more comfortable and thus be more effective at what they do."

Image copyright Wayne Simpson Image caption Steve Carlisle says President Donald Trump has been a rich source of material

What Mr Carlisle brings to his role at the car giant is exactly what a business professor called Maurice Schweitzer cautiously recommends.

Prof Schweitzer recently co-authored a study entitled Risky Business: When Humour Increases and Decreases Status.

It found that a worker or boss who successfully use humour is seen as both confident and competent, which in turn increases his or her status.

"In the workplace context, people look up to those who are confident," says Prof Schweitzer, who works at the University of Philadelphia's Wharton School.

"Being funny is taking a risk, and being risky shows confidence."

Image copyright Maurice Schweitzer Image caption Prof Schweitzer urges any would-be office humorist to be cautious

But do workers think that a humorous colleague is more competent at his or her job?

Prof Schweitzer says that telling a good joke requires both intellect and empathy, which makes colleagues believe that the person has a greater level of competency across the board.

"Being funny requires us to take into consideration other people's points of view, and what they may find funny," he explains.

"And being funny means you understand effective timing, and how to straddle a fine line between what is humorous and what's offensive."

Prof Schweitzer adds that if a person tells inappropriate jokes, be they insulting or unfunny, they are still regarded as more confident, but - perhaps unsurprisingly - also incompetent.

The study says: "Telling inappropriate jokes signals low competence, and the combined effect of high confidence and low competence harms status."

Image copyright Getty Images Image caption Ricky Gervais' toe-curling character David Brent, in The Office, regularly over-stepped the mark when it came to office humour

Essentially, you don't want to be like David Brent, the cringeworthy fictional boss from The Office, the TV comedy series that was a hit on both sides of the Atlantic.

"Humour creates a flattening of relationships in a hierarchal company," says Jennifer Moss, co-founder of Toronto's Plasticity Labs, which conducts research on emotional intelligence and happiness for businesses.

"To create stronger engagement with your staff, it helps to be humorous."

One example Prof Schweitzer cites of a good use of humour is a tweet sent out back in 2009 by former Twitter chief operating officer Dick Costolo.

Mr Costolo tweeted: "First full day as Twitter COO tomorrow. Step one, undermine CEO, consolidate power."

As it happened, Mr Costolo did actually go on to become Twitter's chief executive a year later, holding the role for five years before ultimately leaving the company.

Prof Schweitzer says: "Mr Costolo's not a seasoned veteran when it comes to comedy, he's not a comedian but he endeared himself to the company."

In fact, having some fun in the office can combat negative side effects of intense jobs.

In a 2006 study published in The Journal of Behavioral and Applied Management, researchers found that for healthcare workers, emotional exhaustion was significantly lower among those who experienced greater levels of fun at work.

Image copyright Getty Images Image caption Will someone please file a complaint with HR

Also, research out of Vrije University Amsterdam concluded that teams that share more jokes gave more supportive and constructive statements to each other, such as "that's a great idea" or "we could solve this problem by doing X".

When it comes to the type of humour you might want to try out on your workmates, Prof Schweitzer says that self-deprecation "can be effective" because it humanises the joke-teller.

Sarcasm can also be effectively used, according to Prof Adam Galinsky of Columbia Business School, but he urges a cautious approach.

He says sarcastic humour works best when trust and playfulness has been established between parties, otherwise a wrongly-placed sarcastic comment can appear flippant or cruel.

"Sarcasm requires a cognitive capacity to understand flexibility of thinking and how words can be interpreted," says Prof Galinsky. "It is a particular type of social intelligence that not everyone uses or grasps."

More stories from the BBC's Business Brain series looking at quirky or unusual business topics from around the world:

Putting the fun back into dance classes

Can you be taught to be more charismatic?

Does selling up mean selling out?

'I turned my dad's erotic novel into a hit podcast'

Would you carry something abroad for a stranger?

Barbara Plester, senior lecturer at the University of Auckland Business, says it is simply vital for jokes to not cause offence.

The author of The Complexity of Workplace Humour: Laughter, Jokers and the Dark Side of Humour, also cautions about high-ranking managers bringing comedy to the office.

"While some managers do retain and use their sense of humour, the potential for causing distress is even greater when you add a power differential," she says.

"Therefore, a manager joking with a subordinate risks not only offending the worker if the humour is taken poorly, but may come in for other accusations, such as sexual harassment, if the humour backfires."

Image copyright Barbara Plester Image caption Workplace expert Barbara Plester wonders if staff just laugh at jokes to please the boss

Ms Plester also warns that senior staff sharing jokes "can never be sure if they are really funny, or if others laugh because the manager has power and so subordinates laugh strategically to please the boss."

Connecticut resident Tim Washer never shied away from being the "funny guy at work", thanks to growing up appreciating comedians and even trying some stand-up.

Now a comedy writer and consultant, Mr Washer says the right wisecrack will ease tension and help bonding.

He says: "If I tell a joke and you laugh, then we've shared a moment and we have something in common."

Follow Business Brain series editor Will Smale on Twitter @WillSmale1