In Late Night, Mindy Kaling plays a woman who gets a job writing jokes for an iconic talk show host, and has a hard time making inroads among the all-male staff.

In many ways, though, the clubby and cliquish men are the least of her problems. Molly (Kaling) always feels she’s one misstep away from being fired, and for the most part that instability can be traced to Katherine Newbury (Emma Thompson), the show’s legendary — and legendarily dictatorial — host.

Katherine has succeeded in the talk show realm by being tough on all of her writers, but is known to be particularly hard on women, so Molly has to tread carefully. She arrives at the show at an auspicious moment — a corporate bigshot (Amy Ryan) is dissatisfied with stagnant ratings and wants the show revamped. So younger, hipper Molly is in a position to help Katherine mine a new audience, if she can navigate Katherine’s whims and avoid causing offense.

Molly is also contending with the inappropriate advances of the staff Lothario (Hugh Dancy) and the hostility of the shows’s head writer (Reid Scott).

Kaling and director Nisha Ganatra, who have done good work on television, have some problems with the arc of longer-form movie comedy. The pace of Molly’s relationship with putative boyfriends and bosses unfolds with a jarring lack of rhythm. Ditto the conflict between Katherine and her bottom-line corporate boss. Basic cinematic building blocks like the transition from one scene to another are sometimes clumsily handled — we are often plopped into the middle of a confrontation, with no explanation of how the characters came to be together.

Still, the movie mainly rides on the chemistry and charm of its two leads, and writer Kaling has given Thompson a substantial character to play — Katherine starts as imperious and judgmental, and add shadings of humility and hidden vulnerability as she goes. We’re reminded of how good Thompson is wearing the mantle of authority (as she did in last year’s underrated The Children Act).

The scenes in which she helps Molly to learn the ropes, and learns from her, are well done. Even so, this mentor/protégé, woman-to-woman relationship has already been done to perfection in The Devil Wears Prada, which had the advantage of a much cleaner lines and less crowded agenda.

Kaling must grapple with the sexism in the world of network joke-writing. Her character, in the end, must make her bones by writing good jokes. It’s a problem for Late Night that the killer, career-making monologue joke featured here is indistinguishable from the throwaway stuff Katherine red-pencils in the writers’ room.

Late Night. Directed by Nisha Ganatra. With Emma Thompson, Mindy Kaling, Reid Scott, Hugh Dancy, Amy Ryan, and John Lithgow. Distributed by Amazon Studios.

Running time: 1 hour, 59 mins.

Parents’ guide: R (language)

Playing at: Area theaters