It must come as a relief to Joanna Scanlan that her latest television character is a lovable human being with a big heart. After playing a bumbling Whitehall press officer in The Thick of It and a status-obsessed nurse in Getting On, her role in the new comedy drama Heading Out couldn't be a bigger contrast: she plays a lifestyle coach.
Those two mild grotesques – Terri Coverley in The Thick of It and Den Flixter in Getting On – were in critically acclaimed comedies. Scanlan co-wrote the delicious comedy noir set in an NHS ward with Jo Brand and Vicki Pepperdine, both of whom also starred in it. Brand received a Bafta for best actress for Getting On in 2011 and the programme is expected to be nominated in this year's awards, which are announced in April.
Heading Out is written by Sue Perkins (of The Great British Bake Off) – she plays Sara, a vet about to turn 40 who is scared to tell her parents that she is gay. It has a stellar castlist including Dawn French, Mel Giedroyc, Steve Pemberton and June Brown; Scanlan is Toria, the hopelessly incompetent lifestyle coach hired by Sara's friends to help her tell the truth about herself.
We speak as gay marriage is about to be legalised, so it may seem strange that coming out is still an issue for some gay men and women. But Scanlan says she recognises Sara all too well.
"There's a world of anomalies around this. On one hand we live – certainly in metropolitan life – with normality and acceptance of all sorts of sexualities, but that doesn't mean that people in themselves are resolved. Sue's script rings very true to me. Fifteen – even five – years ago equal marriage wouldn't have been thought possible; we're moving very fast ... but there are emotional journeys that take longer for some."
Scanlan, whose parents were hoteliers, grew up in north Wales and studied history at Cambridge, where she was in the Footlights. She was there at the same time as Tilda Swinton (hence Swinton's appearance in the final episode of the last series of Getting On), Simon Russell Beale and Hugh Bonneville.
"Hugh and I toured in Romeo and Juliet. He was Romeo," she says. And was she Juliet? "I was not!" she laughs. "I've been playing characters of 40 since I was 10," says 50-year-old Scanlon. "I skipped the Juliet phase. I played her mother, Lady Capulet. I remember, though, the director saying to me, 'I'm going to try some intuitive casting here – you're not going to play the Nurse ....' He spun that really well, I must say."
That anecdote – told with much hilarity – suggests that Scanlan doesn't have a fragile ego, and she says she doesn't mind looking foolish if the role demands it.
"I don't really care how I look," she says. "I'm sure I should have more dignity but it makes it funnier if you go for it. I'm overweight so I might as well use it."
Both The Thick of It and Getting On were partly improvised, so I ask if there is anything of Scanlan in Terri and Den. "I'm quite bossy ... and I can find it quite hard to apologise," she says, groaning. Scanlan might have to convince me on both counts – her hearty laugh punctuates our conversation, and she takes time over her responses.
She does a lot of research for her roles, she says. "I talked to people in those jobs [Whitehall and the NHS] because I cannot possibly know what it feels like to be somebody else unless I have some evidence of what it is to be them. Otherwise there's danger of it becoming a caricature. I was an academic for eight years [five years teaching drama at De Montfort University and three years at the Arts Council], so I suppose I have a trained approach to getting things right."
Heading Out is much lighter in tone than Getting On, but it seems that some of the best dark comedies of recent years have been written by women, Julia Davis's Nighty Night being a case in point.
"Some male comics are superb at the technical aspects of comedy, which is a thing of beauty in itself," says Scanlan. "But [in Getting On] we enjoyed showing the emotional side of our characters. I think that can lend itself to dark comedy when it's true to the reality. We were truthful about not just the sadness and the pain, but also about the banality and boredom of hospital life."
Was there ever a danger of making it too dark? "We had quite a few debates about where the line is drawn but I think instinctively once you get the tone right you know where the comedy lies. My personal instinct is to just do it, because you can always edit it later if need be." (One can imagine the debate about the opening episode, which centred on a freshly laid turd on a chair in Ward B4.)
It was subtly political as well, shining a light on areas of the NHS – care of the elderly and the chronically sick – that other doctors-and-nurses dramas consider unsexy. "Yes, it was political, but we tried to show all angles," Scanlan says. "The public sector is being treated as an opportunity for business, and I don't think business is ever as effective in schools and hospitals."
Getting On had a loyal following among NHS staff, who praised its gritty realism. Scanlan, who lives in south London with her husband, Neil, an accountant, and their rescue dog Millie, supported the campaign by NHS workers to save the A&E department of Lewisham hospital. "I was in contact with a couple of nurses there," she says. "I simply cannot understand the Government's thinking on this."
Scanlan says she has no idea if there will be a fourth series of Getting On, but before that may happen she is developing another project with Pepperdine.
"It's about training dogs, a family comedy about how people relate to their pets. It's going to be much sunnier."
'Heading Out' starts on BBC2 on 26 Feb