Six years after “The Office” went off the air, the dirty secrets are coming out: Mindy Kaling was almost stripped of her producer credit — putting her ability to earn an Emmy nomination at risk.

In an interview for Elle’s 2019 Women in Hollywood issue, Kaling — who starred on the nine-season NBC hit as Kelly Kapoor, and also served as a writer-producer — says that the Television Academy tried to remove her production credit because there were “too many producers” on the hit comedy.

“They made me, not any of the other producers, fill out a whole form and write an essay about all my contributions as a writer and a producer,” Kaling said. “I had to get letters from all the other male, white producers saying that I had contributed, when my actual record stood for itself.”

She said this move sparked a feud with the Academy, the industry body that determines eligibility for Emmy Award nominations.

In a statement to the Los Angeles Times, an Academy spokesperson responded to her allegation: “No one person was singled out. There was an increasing concern years ago regarding the number of performers and writers seeking producer credits. At the time the Producers Guild worked with the Television Academy to correctly vet producer eligibility.”

In response, Kaling posted a Twitter thread: “Hey, @TelevisionAcad! I have been a proud member for years,” she wrote. “I was the 1st woman of color nominated for writing a comedy script. Why not say, ‘years ago we prevented a deserving woman of color from getting credit for her accomplishments. We’re sorry and it would never happen now.’?”

In another comment on Twitter, Kaling, now a six-time Emmy nominee, added, “I’ve never wanted to bring up that incident because ‘The Office’ was one of the greatest creative experiences of my life. And who would want to have an adversarial relationship with the Academy, who has the ongoing power to enhance our careers with awards? But I worked so hard and it was humiliating…Not mentioning it seemed like glossing over my story. This was like ten years ago. Maybe it wouldn’t happen now. But it happened to me.”

“The Office” is currently streaming on Netflix, where it’s found a new audience among Gen Z teens.

In January, Amazon paid $13 million for the US distribution rights to Kaling’s big-screen writing debut, “Late Night.” That payout set a new domestic purchase record for the Sundance Film Festival.