NBC's successful sitcom The Office finished airing back in 2013, but its popularity has only risen since then. The show focuses on the Scranton branch of Dunder Mifflin Inc., a paper supply company, and the people who work there. There's a pivotal moment during Season 3 when it becomes almost certain that the Scranton branch will close due to downsizing, seemingly jeopardizing the continuation of the show, but the thing that ultimately stops this disaster is Staples -- Dunder Mifflin's number one competitor.

At the end of Season 2, Jim Halpert transfers to the Stamford branch of Dunder Mifflin to avoid seeing Pam Beesly, his unrequited love. The Stamford branch is run by Josh Porter, a young, up-and-coming manager with lots of potential, at least when compared to Michael Scott, the manager of the Scranton branch. Dunder Mifflin, since the very first episode, has been trying to downsize and cut back on costs. Upon comparing the Scranton and Stamford branches, along with their managers, it becomes clear which branch should be shut down -- Scranton.

RELATED: Peacock Hits a Major Milestone, Thanks to The Office's Arrival

Now, this is a dire circumstance for the staff of the Scranton branch, including Michael Scott. Even his managerial position isn't protected in this case. For a few scenes in Season 3, Episode 7, "Branch Closing," it seems like all hope is lost for the Scranton branch, but when Josh is approached by Jan to discuss the merger of the branches, Josh informs her that he's actually taken a position at another job. He's to be a senior manager for Staples, Dunder Mifflin's top competitor.

Jan immediately sees that Josh gave up his promotion with Dunder Mifflin for a better offer at Staples, which is frustrating since the entire restructuring was centered around keeping Josh in the company. He ends up leaving at the very last minute, and while this leaves corporate scrambling for a bit, it's a godsend for the Scranton branch.

TV The-Office cast

With no manager left at the Stamford branch, corporate reorganizes and decides to close Stamford and have it merge with Scranton, under the management of Michael Scott. If Josh had accepted the Dunder Mifflin promotion, Scranton would have closed, and The Office would have had to reroute its entire plot. Thanks to the talented writing team, Scranton remains open, and Jim Halpert finds his way back to his old branch.

RELATED: The Office: Why Kevin Lost His Job at Dunder Mifflin in Season 9

Although Josh seems like the catalyst for Scranton's salvation, it's actually Staples. Without their offer for the senior management position, Josh would have stayed at Dunder Mifflin, likely until another offer came along. For the purposes of the storyline, Staples is what ultimately saved the Scranton branch. When it comes down to Josh's choice, of course he's going to take the better job at Staples.

This isn't the first time Staples has unknowingly contributed to Dunder Mifflin's overall wellbeing. When Dwight Schrute resigns from Dunder Mifflin in Season 3, Episode 13, "Travelling Salesman," he leaves to work for Staples, which is a low-blow for Michael Scott as Staples and other big-box stores are what could put Dunder Mifflin out of business. Eventually Michael convinces Dwight to come back, and Dwight makes sure to take a bunch of customer files with him, giving business back to Dunder Mifflin.

Staples, while being Dunder Mifflin's main business competitor, has both contributed to and saved the Scranton branch throughout The Office. While Staples is definitely pinned as the bad guy in multiple anecdotes throughout the show, it ultimately is what kept the Scranton branch afloat in times when everything could've been lost.

KEEP READING: The Office: How Ryan Became a Dunder Mifflin Executive