Truly one of the most iconic relationships in TV history is Jim and Pam from The Office, but an alternative plan for the show’s final season would have seen the couple completely split up.

Fans of The Office delighted when John Krasinski’s Jim and Jenna Fischer’s Pam finally got together in Season 3 after three years of flirting and longing from afar, and as the show progressed things were pretty much peachy for this #relationshipgoals couple all the time. Until Season 9, that is.

Quite possibly the most stressful season in The Office’s history, the ninth and final season saw Jim and Pam’s relationship strained in a really significant way as Jim took a job in Philly and Pam struggled to take care of their children alone. In one of the most unforgettable moments in TV history, a particularly testy phone call between the two ends with Pam in tears, with Fischer’s character turning to someone off camera named “Brian” for advice. And thus The Office finally broke the fourth wall.

Indeed, the Brian storyline was insanely divisive. The idea was to show the camera crew for the first time in the show’s final season, but an added twist here was that Brian (played by Chris Diamantopoulos) was actually secretly in love with Pam, and their relationship threatened to drive a wedge even further between Jim and Pam.

And if you think you hate the Brian storyline now, just wait until you hear about how the show was supposed to actually split Jim and Pam up entirely, only for the two to reconcile during the series finale.

As recounted in Andy Greene’s new book The Office: The Untold Story of the Greatest Sitcom of the 2000s, the idea of shaking up Jim and Pam’s relationship came from creator Greg Daniels, who resumed his role as showrunner in Season 9 for the first time since Season 5, when he stopped working full-time on The Office to co-create Parks and Recreation with fellow Office writer Michael Schur. Daniels sat down with all the actors before starting Season 9 to discuss where their characters would go, and Krasinski lobbied to put Jim and Pam’s relationship on shaky ground. Krasinski said:

“My whole pitch to Greg was that we’ve done so much with Jim and Pam, and now, after marriage and kids, there was a bit of a lull there, I think, for them about what they wanted to do… For me it was, ‘Can you have this perfect relationship go through a split and keep it the same?’ which of course you can’t. And I said to Greg, ‘It would be really interesting to see how that split will affect two people that you know so well.’”

Writer Brent Forrester reveals that they set out to actually have Jim and Pam break up in the middle of the season, with the idea being that in the series finale’s reunion episode, they would rekindle their relationship:

“Greg really wanted to do something extremely risky and high-stakes, which was the documentary airs and we see what effect it has had on these characters. And there was going to be a reunion episode where you see that Jim and Pam have split up by this time, and they will have their reunion in the reunion episode.”

Warren Lieberstein, who was a writer on the series, remembers that this idea “wasn’t universally loved” in the writers room but Greg had the final say, so they began enacting this plan. A plan that Daniels said had been in the offing since Season 5:

“[This] was something that came up in season five, I think. It was a pitch. I think Mindy [Kaling] was the first or one of the first champions of it. The idea was to introduce some romantic triangle with Jim when they were such soul mates that you had to say, ‘How could she possibly be interested in somebody else?’ You think to yourself, ‘Well, I wouldn’t believe it if I just was introduced to the character.’ You had to see it happening from scratch. What if that character had been secretly there the entire time and predated the relationship with Jim and had been a shoulder that she cried on for years?’ It just seemed very intriguing. But we also were like, ‘If we break the fourth wall in season five, it feels like that might be the last season for the show.’ So we kept putting that off.”

Writer Owen Ellickson says there was even some talk of Pam and Brian “maybe hooking up a little bit,” but Daniels says he never intended for their relationship to get that far:

“Ultimately, I didn’t think it was about actually going there. They never did anything. It was just to introduce worry in the audience, which I think happened. I mean there are people who in season eight were like, ‘They’re so boring. They just hang out together and there’s no angst. We used to love the angst with their relationship.’”

But fan response to the Brian twist was intense to say the least, and the plotline didn’t play out the way the writers and producers were hoping. As a result, they had to rework the entire storyline in the middle of the season. Forester recalls how Krasinski came to him and implored him to get Jim and Pam back together ASAP:

“We had to pull the ripcord on it because it was so painful to the fans of the show. John Krasinski said to me, ‘Brent, this final season is for the ultra fans of the show. They’re the only ones really still left watching, right? This is for them. Jim and Pam splitting up is too painful for them to sustain all the way to the reunion. We have to get them back together immediately.’ I was like, ‘Wow, we can’t allow this beautiful couple to be really like on the verge of divorce. It’s too awful for them.”

Ellickson reveals that they reversed-course so quickly, they had to re-edit episodes that had already been shot to nix the idea of Jim and Pam splitting up completely:

“The episode that really spun people on a dime is one that I wrote [“Vandalism”] where Brian the boom guy heroically saves Pam from an attack from a warehouse guy. People just absolutely did not like that. They were bothered that there might be some triangle that Pam and Jim would be involved in and even more insulted that we thought they might believe that. That’s how it felt to me. Greg absolutely turned on a dime after that and we pivoted away, I think pretty skillfully given how quickly we had to do that. It involved decently sized edits to the next two episodes, if I recall.”

And pivot they did. Jim and Pam do end up together, with that iconic note from Season 2 making an emotional return, but if you felt severe anxiety that the two might not make it, that was a remnant from a cancelled storyline. And I think they made the right call here—some strife in the relationship did make things interesting, but bringing Brian in as a third wheel was a bridge too far.

For more on The Office be sure to pick up Greene’s book, which also reveals the real reason why Steve Carell left the show.