When the Lakers traded D’Angelo Russell, they claimed it was done solely for on-court reasons. Now Magic Johnson finally admitted the Nets landed their 23-year-old All-Star thanks to his Snapchat snafu.

In Monday’s explosive interview on ESPN’s “First Take,” Johnson acknowledged that after Russell had surreptitiously recorded teammate Nick Young’s confession of infidelity — and shared it on Snapchat — he knew he had to deal away the young guard.

“I said let’s trade some people, get some draft picks, so on and on. D’Angelo, great guard, but had a problem when Shaggy P and the whole Nick, the whole thing went down,” Johnson said. “So I knew we had to get him out.”

The Nets are glad Johnson did. General manager Sean Marks, who had known Russell since the guard’s time at Ohio State, was more than happy to pounce and deal for the 2015 No. 2 overall pick two summers ago in a devalued state.

It’s the first time Johnson had acknowledged Russell’s social media gaffe as the driving force behind the deal. Up until now, he and the Lakers had always cited on-court reasons.

“He has the talent to be an All-Star. We want to thank him for what he did for us. But what I needed was a leader,” Johnson claimed at the time. “I needed somebody also that can make the other players better and also [somebody] that players want to play with.”

For those who need a refresher, Russell had recorded Young — known as Swaggy P, but forgive Johnson for not keeping up with the nicknames — admitting he’d cheated on then-fiancée Iggy Azalea. Then after Russell posted the recording on his private Snapchat account, it leaked. Young and Azalea subsequently split.

And so did Russell and the Lakers.

Johnson was desperate to get rid of Timofey Mozgov’s bloated contract, and the Nets had plenty of cap space to handle a salary dump. When Marks agreed to part with the 27th overall pick (that eventually became Kyle Kuzma), Johnson gladly traded away Russell.

“We felt good about making that deal,” Johnson said Monday.

But this season, Russell blossomed with a career-best campaign. He averaged 21.1 points, 7.0 assists and earned his first All-Star berth in carrying the Nets to a surprising sixth-place finish in the Eastern Conference.

Russell will be a restricted free agent in July unless the Nets can lock him up to an extension before he hits the open market.

The Nets lost their fourth coach/executive this summer, as Gianluca Pascucci left for the Timberwolves

The agreement — first reported by ESPN and confirmed by The Post — continues a brain drain on the Nets’ front-office staff.

Coach Kenny Atkinson had credited Pascucci, the Nets’ director of global scouting, with finding second-round steal Rodions Kurucs.