After this the king of the Ammonites died, and Hanun his son reigned in his place. And David said, “I will deal loyally with Hanun the son of Nahash, as his father dealt loyally with me.” So David sent by his servants to console him concerning his father. And David’s servants came into the land of the Ammonites. But the princes of the Ammonites said to Hanun their lord, “Do you think, because David has sent comforters to you, that he is honoring your father? Has not David sent his servants to you to search the city and to spy it out and to overthrow it?” So Hanun took David’s servants and shaved off half the beard of each and cut off their garments in the middle, at their hips, and sent them away. When it was told David, he sent to meet them, for the men were greatly ashamed. And the king said, “Remain at Jericho until your beards have grown and then return.” 2 Samuel 10:1-5.
If Hanun was trying to avoid having a war with David why would he provoked him? It must have been the foolish decision of his advisors, who wanted to make a name for themselves and appear like tough guys.