The Mavs are struggling in the Wild West, so there's a possibility they could shift their focus from winning now to building around Flagg. The Pistons are in a wide-open East and look like they are 1 big trade away from becoming serious contenders. Here's how both teams could help each other:
Mavs flip AD / Naji for a huge haul of picks and young players with high potential to better their future with Flagg. To make the money work, they take on Tobias who they can let go next Free Agency and free up cap space to better their future even more
Pistons go all in and become the #1 contender in the East with the additions of AD and Naji who are perfect fits. It's risky taking on AD because of injuries, but when you have bigs like Duren/Stewart/Reed to share the load in the regular season, that gives AD a great chance at being healthy come playoff time
Pistons Rotation (when healthy) :
PG: Cade / Sasser
SG: Robinson / LeVert
SF: Thompson / Naji / Javonte
PF: AD / Stewart
C: Duren / Reed
Mavs Rotation (when healthy) :
PG: Kyrie / D'Lo
SG: Ivey / Klay / Christie
SF: Flagg / Holland / Martin
PF: Washington / Harris
C: Lively / Gafford