[Warning: This story contains spoilers from Sunday's episode of Veep, "A Woman First."]

In the alternate universe of Veep — where the most recent real president mentioned is Ronald Reagan — Sunday's episode revealed that Adam Scott is hosting the Tonight Show. Initially, however, the job was David Letterman's for the taking.

"We took a lot of inspiration from when Sen. John McCain was running for president," Veep showrunner David Mandel tells The Hollywood Reporter of when the then-presidential candidate bailed on Letterman's Late Show. "Letterman caught him doing the Katie Couric show, also on CBS, and tore him apart. So we started thinking about the Tonight Show or a talk show where Selina would cancel and cancel and cancel because of her book, and then pay the price."

Mandel says he and Julia Louis-Dreyfus then reached out to Letterman, a Veep fan, to see if he would want to play himself on the HBO comedy.

"The idea being that in alternate Veep world, he became the host of the Tonight Show when Johnny Carson retired," Mandel explains of their pitch. "He was incredibly kind and gracious, but just as he put it to New York Magazine, he didn’t want to get behind the desk again in any way, shape or form."

That's how Scott came to sit behind Veep's Tonight Show desk — a set for which Mandel gives "amazing kudos" to the production team. Veep executive producer Morgan Sackett, along with several crewmembers, had worked with Scott on Parks and Recreation and, knowing he too was a Veep fan, asked him to play the host.

"We never identify him as Adam Scott specifically, so you can think about it anyway you want: Either as Adam Scott, or as Adam Scott playing someone," says Mandel of the scene, which sees the Tonight Show host taking ex-president Selina Meyer (Louis-Dreyfus) to task for flaking on his show after revelations about her presidency hit the press. "Watching Adam Scott, I can tell you he was clearly a huge Letterman fan and was channeling Letterman at his sort of prickly best. The tones, rhythms, off-handed comments, self-deprecation and almost self-loathing when he talks about what a terrible show he’s hosting."

The episode delivered a monumental upswing to Meyer, who is finally receiving the recognition she deserves for freeing Tibet, thanks to Mike (Matt Walsh) accidentally leaving his diary on the presidency in the hands of a Washington Post reporter. In a chat below, Mandel talks to THR about the surprising win, the comment the show is making on the short attention span of the media and why bringing Uncle Jeff (Peter MacNicol) back to destroy Jonah was a cameo that required patience.

How did you land on the idea of Selina getting taken to task on Veep's Tonight Show?

Without bogging people down in some weird, alternate history lesson, we’ve always said that Veep exists in this other universe where we only mention presidents up to Ronald Reagan. Nixon, Ford, Carter Reagan, and then we get into President Stevens and so and so. Originally, were just thinking of doing a book party, but we just had Gary’s birthday and the portrait unveiling, and we never want to feel like we’re repeating ourselves. We played with different versions of how much we would show and we picked someone we thought would be really funny. So, it was inspired by Letterman, we tried to get him, we got Adam Scott and it worked out fantastic.

Do you think Letterman will enjoy the episode?

I hope he gets a kick out of it. He’s a viewer. When we explained the inspiration, he understood why that would be funny. If memory serves, he laughed at the idea of the kids reading the bad reviews of Selina’s book.

Courtesy of Colleen Hayes/HBO

Mike’s biggest screw-up ever is now playing itself out. Why did you solve this epic disaster rather quickly, and flip it around to give Selina a win?

It was Mike’s biggest f— up ever, but in some ways he saved the day — in the very bizarre way Mike can. We were playing with the content of the last couple of episodes. The book was going to come out earlier and this episode was going to be Gary’s birthday party, but we realized we needed more time on the book. The plan was that when Mike sat down to do this and that his notebook would fall into Leon West’s hands in a very Veep way, it would end up revealing the truth about all of Selina’s misdoings, but that the media would concentrate only on the one thing, which seemed like a good comment to be making, but also a fun comment to be making.

This has been Veep’s season taking on the media. What are you trying to say about what makes headline news?

I don’t know if it’s an original thought, but it’s certainly one worth saying from our perspective as much as we could. We have a president sitting in the White House who from time to time seems to be able to distract the entire media with a single tweet. Who has said horrific things only for them to be forgotten five seconds later by, not just the media, but also the public. On vacation, I watch other people on vacation sitting at the pool looking at their phones, or in the pool looking at their phones in these weird waterproof cases. And I just think things come and go. We are living in a real-world version of short-attention-span theater. It seemed like an interesting thing to have everything go wrong but have this one thing go well. And Selina deserves a victory every now and then.

When everything was going badly, she said, “I could go to jail.”

We only listed some of the highlights, but she mentioned a couple of seasons ago the data mining of the dead children, which was a huge thing and something she lied about at the hearings, as did most of her staff. They talk about stuff that happened in Georgia this season, she mentions a drone attack on some terrorist guy and we don’t even know what that was. She obviously did a lot of things during her presidency, so God knows what she was up to. But at the end of the day, she is the woman that freed Tibet.

How does this ability to distract from the larger issues at play reflect a scary truth about our current world?

It’s one of the truths of what we’re talking about, but I always want to clarify that it was not the inspiration. I think it’s somewhere we’ve been headed over the last 10 years, unfortunately. Which is, whatever fits in the standard iPhone headline, the content doesn’t necessarily matter.

During her visit on the Tonight Show, she’s not exactly being celebrated, despite the truth about Tibet being the big headline. Where does her reputation stand coming out of this?

You’ll see it in the beginning of the next episode, which is the season finale, that she’s going to get a lot of good coming to her due to Tibet. You never want to overdo it, but it’s at least a reconsideration of her.

When President Montez [Andrea Savage] stole Tibet from her last season, did you know then and there you wanted to slowly right the wrong this season?

No. When Montez got the credit, we were not necessarily sitting there saying, “Now we can do this.” But it was definitely something we knew that Selina would be obsessed with and that we could have fun with, so this is what we came up with. Now, especially as you watch this episode and the next one, you can look back on the season and really see that beyond her role in the universe, specifically, Montez taking credit for the Tibet thing really motivated a lot of her actions. Not that Selina thought she could get the credit, but that she was looking for something like Tibet. In the case of the Chinese and when she was in Qatar, you can see that a lot of this season has been about Selina trying to find her place in the world. Tibet was one of her few real, bona fide accomplishments that she couldn’t talk about, and now she’s finally gotten it. As we heard with the end of the episode, even Yale University is now interested in her presidential library. So this is coming back to the first and second episode of her desire for the library, which takes us right into the groundbreaking ceremonies next week.

She might not totally deserve it, but it’s nice to see her get a win. Should viewers not hold their breath that the momentum will last?

Even in this week, she had her victory but then took it on the Tonight Show. Everything isn’t always perfect in her world, but everything can’t always be a downer. There’s no pattern to it, but I love seeing how she reacts. Sometimes we come up with an idea and then think, “What would Selina do?” That’s one of the things about this character, it’s always interesting to run her through the rat race in the laboratory. A lot of characters are down but for once, Selina isn’t. That’s a little different because Selina had been riding so low for a really long time, and Jonah [Timothy Simons] had been riding so high, so we wanted to mix things up and surprise people.

Selina is back with Jaffar [Usman Ally] but now with all this excitement going on, where does a relationship rank?

She’s finally coming out of her father, Andrew and Tom James and all of this stuff, and there’s a relationship there. One of the things we definitely wanted to do with this episode was to be jumping forward in time from the last episode in Alabama. When they pull up to her place together, there’s a real sense that they’ve been spending a tremendous amount of time together. It’s been fun having her find her way to an actually decent human being like Jaffar.

Viewers have tracked Jonah’s rise for nearly two seasons now, and Sunday’s episode delivered his fall. Who is your real-life inspiration been for Jonah this season?

Ted Cruz, also elements of Newt Gingrich. There’s a famous story that the government shutdown under former President Bill Clinton basically happened because Newt Gingrich got a bad seat on Air Force One. In some ways, that was an element of Jonah not getting invited to Selina's portrait unveiling [and then causing the government shutdown]. All of these things tie together. It’s our version of the Tea Party and the Freedom Caucus, but it’s also our version of any outlying group that can, by sheer numbers, dominate the Senate or the Congress. This was our take on these types of people and Gingrich and Cruz are two of them. With Cruz, a lot has been said about how people just don’t like him, and that’s certainly very Jonah. Even the people working with Jonah don’t like him. He got really close and there was a moment there in the previous episode where, if he had taken the deal in the Oval office, God knows what could have happened. As Ben [Kevin Dunn] says, “God help us, who knows?” But he didn’t, and there we are.

Why was Uncle Jeff (MacNicol) necessary to return and deliver the final blow?

We actually shot a scene with Uncle Jeff in the first episode earlier in the year and knowing we had this big Uncle Jeff scene coming up, we realized, “Let’s not have him, let’s wait. Let’s wait and wait and wait, so that when he walks in it’s like: Kablam!” That way, maybe the audience isn’t thinking about him at all. It was wonderful to have Peter MacNicol back. I don’t quite know how any of us made it through that scene. To watch Tim’s face and poor Mary Holland, who had never done a scene with Uncle Jeff before — I think the actress herself is reacting to some of the stuff he is saying about her character Shawnee. (Laughs.) Tim at least has done Uncle Jeff scenes.

In the writers room, are you all chomping at the bit to contribute to an Uncle Jeff rant?

The episode was written by Eric Kenward, who splits his time with us and Saturday Night Live, so we’re always lucky to have him. The writer always takes the first stab, and there was a bunch of good stuff, and then we all just throw in. Everyone wants to throw in a Furlong [Dan Bakkedahl] line or an Uncle Jeff line. We’re just looking for that perfect blend of awfulness. And with Peter, we worked together last year and now this year, he’s such a great actor but it’s always funny because when he comes back. I always get lulled into who he is as a human being, and then when he just lets loose as Uncle Jeff, I’m in awe about the actor he is. I have to bite my hand watching the scenes.

To have this happening to Jonah two minutes after his circumcision, is this ultimate payback for everything he has done?

I never want to think it’s the ultimate payback, but I think Jonah just made one too many Jewish jokes. The day we knew that he was going to convert to Judaism is the day we knew he was going to get a circumcision.

What does Jonah’s future look like now?

It’s pretty bleak. Uncle Jeff has the control and cousin Ezra will be the new Congressman from New Hampshire. Jonah’s going to have to figure some things out.

Dan also gets the boot from CBS This Morning – was Jane's Jonah scoop the final nail in the coffin?

The first step was that he has no chemistry with co-anchor Brie, even though they were actually having sex. But Jonah really did screw him over. He ruined his own chances as well as Dan’s last episode. I’ve said about Jane McCabe [Margaret Colin] — if you’re going to push her out, put a spike in her and cut her head off. She’s going to come back and is not someone to be taken lightly. We drew inspiration from some of the famous morning show firings, but it was an Ann Curry twist. Ann Curry never came back and got Matt Lauer fired, but this was our take. We’re not just doing things that happened. We take these things as inspiration for story ideas and this, to us, was the perfect capper. Dan is calling Ben at the end of the episode, so you’ll have to wait to see his next move.

Catherine actually went to the ER at the end of the episode — are she and the baby OK?

Catherine is OK, just a little bleeding. The good news is, they didn’t get anything on the couch. (Laughs.) Sarah [Sutherland] and Clea [DuVall] are really having fun this season and it was very fun to have Clea with Julia for the scenes where everyone is ignoring Catherine when she’s on the couch and Selina is stuck talking with Marjorie.

Last season ended with a game-changer. What can we expect from the finale?

We’ve been slowly lining the pieces up. Hopefully, people can see a lot of these little seeds were laid down in the beginning of the season and what we like to do is to have a lot of those seeds pay off. People are going to be very surprised to see Selina actually getting something she wants.

What did you think of the episode and what do you want to see from the finale (airing Sunday at 10:20 p.m. on HBO)? Tell THR in the comments below and head here for full Veep show coverage.