The final two seasons of “The Office” almost looked a little more like “The Sopranos”.

Gandolfini was offered to lead Dunder Mifflin’s Scranton branch following the departure of Michael Scott (Steve Carell) at the end of season 7, according to “The Sopranos” co-stars and “Talking Sopranos” podcast hosts Michael Imperioli and Steve Schirripa. The actors said that HBO paid Gandolfini $3 million to turn down the role and preserve his mobster legacy.

RELATED: Chris Rock Turned Down Multiple Offers To Appear On ‘The Sopranos’

“I think before James Spader and after [Steve] Carell, they offered Jim, I want to say $4 million to play him for the season — and HBO paid him $3 million not to do it,” Imperioli said. “That’s a fact.”

“So they paid him that to keep the legacy of ‘The Sopranos’ pure?” guest Ricky Gervais, who starred on the original, British version of “The Office”, asked the hosts. “Well, that’s a good decision.”

There was another situation that factored into HBO’s lucrative offer.

RELATED: Alec Baldwin Tried To Convince ‘Sopranos’ Creators To Let Him Kill Tony Soprano

“Jim was going to do it because he hadn’t worked and it was a number of years removed from when the show ended,” Schirripa explained. “I guess that and also he had a deal with them… ’The Night Of’, he was developing that.”

The HBO crime thriller “The Night Of” did not debut until 2016, approximately three years after Gandolfini’s death. The “Sopranos” star died at age 51 in Rome, Italy, of a heart attack. His son Michael Gandolfini will star as a young Tony Soprano in HBO’s prequel film “The Many Saints of Newark” premiering in theatres on October 1.