Nahnatchka Khan was busy working on a script last year when she got the we’re-making-your-pilot call that every TV writer hopes to receive.

But she was also confused — because she hadn’t even turned in her first draft. As it turned out, ABC topper Paul Lee had flipped for a script she’d written two years earlier for Fox.

Last week, Khan, a sitcom vet whose credits include “American Dad,” “Good Morning Miami” and “Malcolm in the Middle,” finally got the chance to unleash the show she’s been living with for the past three years. “Don’t Trust the B—- in Apartment 23,” a femme odd couple comedy starring Krysten Ritter, Dreama Walker and James Van Der Beek (as himself), marks her first created-by credit; Khan is co-showrunner with David Hemingson. ABC is giving it the best possible launch campaign, slotting it in the coveted post-“Modern Family” Wednesday 9:30 p.m. slot, where it bowed to a solid 7 million viewers.

Hardest part of getting there: “In my last season on ‘American Dad’ I got bumped up to executive producer, but this is the first time running my own show. I was expecting it to be insane and crazy, but nowhere near the level it was. You can’t prepare for something like that. It’s just something you go into.”

Inspiration point: “For me the idea of women behaving badly is very interesting. And one of my favorite movies of all time is ‘Breakfast at Tiffany’s.’ I thought about Holly Golightly and what that character would look like today. I thought about that larger-than-life character (Chloe on “B—-“) having a normal roommate, to put her in perspective: somebody who just comes home at night, watches ‘Castle’ and pays the gas bill.”

Finding Chloe: “When I realized, ‘Oh my god we’re making this show,’ the first thing we had to do was figure out who would play Chloe. I had seen (Ritter’s) feature stuff, and when we met her in person, she was amazing. She did a screen test and the first sentence she read, I remember looking around and saying, ‘This is it.’ She made it even better than I thought it was.”

How ’bout that title: “I’m really happy (ABC) stuck with it. There was talk of shortening it to ‘Apartment 23,’ but I made a plea to Paul (Lee) to keep it. For me it was not so much the word ‘Bitch’ but the warning part of it. I wanted a word that implied danger. … There’s a French painter, Jacques Flechemuller, who did a painting that has written on the bottom: ‘Beware the tenants in 23.’ I loved the idea of subverting that for a comedy.”

After graduating from USC film school: “My first job was working for Disney TV Animation. They hired us to come up with TV show ideas based on Disney properties. We got paid virtually no money, but through that I got my first work on a pilot, a show called ‘Pepper Ann.’ I had no experience running a show. I faked my way through production meetings. From there, I went to ‘Malcolm in the Middle’ and into primetime.”

Why she pursued the scribe path: “I’ve always known I wanted to do this. I kind of envy those people who sort of wandered around, trying to figure out what they wanted to do in life. Nobody in my family was in the movie business, but my dad was a huge old movie buff. He would wake me up in the middle of the night to watch ‘Ben Hur,’ and all kinds of movies.”