Praise be to Allah.
Every Muslim must fear Allaah and show respect towards Him. When he stands in prayer before Allaah, he must stand in a manner of humility and submission to Allaah, keeping far away from everything that may corrupt or invalidate his prayer, distract his mind, or keep him from focusing on the prayer. He must avoid anything that goes against respect and good manners.
For a worshipper to have chewing gum in his mouth is undoubtedly incompatible with fear and respect of Allaah, and with humility before Him. It causes a lot of movement in the mouth.
With regard to the ruling on having chewing gum in one’s mouth when praying:
Ibn Qudaamah said: If he has anything in his mouth that can dissolve, such as sugar, and any part of it dissolves, and he swallows it, then his prayer is invalidated, because he has eaten.
(al-Mughni, part 1, p. 400)
According to the Hanafis, Maaliks and Hanbalis, it is also makrooh to put anything in his mouth even if that does not prevent him from reciting, because that distracts his mind. The Hanafis stated that if this thing does not dissolve then it is makrooh; if it does dissolve, such as sugar in his mouth, then this invalidates his prayer if he swallows it after it has dissolved.
(al-Mawsoo’ah al-Fiqhiyyah, part 27, p. 117)
And they stated that if he has sugar in his mouth, and it dissolves and he swallows it deliberately, knowing that that is forbidden, or because he did not make any effort to learn, then his prayer is invalid. They also stated that his prayer becomes invalid if he chews it, if it is a lot, even if nothing reaches his stomach.
Al-Majd said: if he brings out something substantial that is between his teeth and swallows it, then his prayer becomes invalid in our view. They stated that swallowing something that has dissolved, such as sugar, is like eating.
Al-Mawsoo’ah al-Fiqhiyyah, part 27, p. 125