Harry should invite whom he likes; he and Obama are friends, having worked together on Wounded Warriors, the Invictus Games, and other projects. Obama is also a friend of William's, has met the Queen, whom it has been said, liked both Barack and Michelle Obama. This qualifies for an invitation.
(At the time of William's wedding, the Obamas had not established a friendship with the royals; William's wedding was not a state occasion, so all world leaders were not invited.)
Harry and William do not like Donald Trump, a strutting, self-important, foolish cockalorum who boasted that he could have "had" Diana if he wished. Trump is not a friend of the Mountbatten-Windsors, nor of the Spencer family. Harry's wedding is a family occasion, not a state occasion where all of the world's leaders could be invited, known or not.
Harry does not have to invite Donald Trump just because Trump hold office as President of the United States.