Mindy Kaling on how her job on 'The Office' inspired new film 'Late Night': 'I was a diversity hire'

Late Night, the new comedy written by and starring Mindy Kaling as an inexperienced television scribe brought in to shake up a fading talk show hosted by Emma Thompson, is honest and topical in its handling of race and gender and the roles both play in an entertainment industry in long overdue transition.

Molly Patel (Kaling) is hired onto the staff of Katherine Newbury's (Thompson) joke writing team for one key reason: She's a woman, and they desperately need a female perspective. Members of the all-white-male writer's room, meanwhile, are threatened by her presence: "I wish I was a woman of color so I could just get any job I want," one of them bemoans.

The premise is deeply personal for Kaling, 39, whose Indian parents immigrated to the U.S. the year she was born and who rose to fame as a writer and ensemble cast member on the NBC hit The Office starting in 2005.

"I thought it was fun to actually talk about diversity hires in a really open way, because I was a diversity hire for The Office," Kaling told Yahoo Entertainment in a recent interview (watch above), where she was joined by her Oscar-winning costar Thompson. "I came up through the NBC diversity hiring [program].

"And I used to be so embarrassed about that. I was so embarrassed that people would know about it. And I wouldn’t tell anyone. … The other writers will think that was the only reason I was hired."

Kaling was the only woman on the The Office's writing staff when she was first hired at the age of 24, and began appearing as Kelly Kapoor in the series' second episode — called "Diversity Day." By 2012 she had her own hit sitcom, The Mindy Project, and has since appeared in tentpole films like Inside Out (2015), A Wrinkle in Time (2018) and Ocean's 8 (2018). In January, Late Night sold to Amazon Studios for a record $13 million at the Sundance Film Festival.

"What I didn't realize then was that it wasn't something to be ashamed of, that this really great organization was giving me something that other people have born access to, and I won't ever be embarrassed about it again," Kaling explained.

"What's great about the movie is we make no bones about it. She was strictly hired for that reason and then sort of blossomed through that role. So I thought that was really nice to be able to write about."

Late Night opens in select theaters June 7. Visit Fandango for showtimes and tickets. Watch the trailer:

Read more on Yahoo Entertainment:

Want daily pop culture news delivered to your inbox? Sign up here for Yahoo Entertainment & Lifestyle's newsletter.