I'm assuming in this scenario Obama served eight years as Hillary's VP.
Anyways, it's really hard to win three consecutive terms for one's party, but Trump got really lucky in 2016 IRL that he was facing Hillary, who was a poor campaigner. Facing a superior campaigner in Obama, he'd lose.
VPOTUS Barack Obama (D-IL)/Senator Elizabeth Warren (D-MA) 54%
Businessman Donald Trump (R-NY)/Governor Mike Pence (R-IN) 45%
Obama would win a lot more electoral votes with 54% of the vote. That mark has never been exceeded since 1984. I don't think this is even possible with polarization these days, let alone after someone runs for a third term of his party.
Obama definitely would have run a better campaign than Hillary in 2016, so he defeats Trump.