Ruling on reading a commentary on the Qur’an whilst praying
Question

                I would like to ask about the ruling on reading a commentary on the Qur’an (tafseer) whilst praying, as some Mushafs contain a tafseer and mention of the reasons for revelation, and so on.
Praise be to Allah.Firstly:
The questioner should look at the commentary on the verses that he is going to recite in the prayer outside of the prayer first, i.e., before starting to pray, so that he will be free to focus on his recitation and reflect on the meanings.
Ibn Katheer said: The verse “and stand before Allah, devoutly obedient” [al-Baqarah 2:238] means: with humility, humbling oneself before Him. This requires not speaking whilst praying, because that defeats the purpose. Hence, when the Prophet (blessings and peace of Allah be upon him) did not return the greeting of Ibn Mas‘ood when the latter greeted him when he was praying, he apologized to him for that, and said: “Prayer is a preoccupation.”
End quote from at-Tafseer (1/654).
The hadith was narrated by al-Bukhaari (1216).
Secondly:
The fuqaha’ stated that reading in books whilst praying is makrooh, although some of them said that there is nothing wrong with it, subject to two conditions:

That he be only looking at the tafseer, and not moving his lips whilst reading;
it should not require a great deal of movement, such as picking up the book, opening it, and turning the pages, because a great deal of movement invalidates the prayer.

Imam an-Nawawi (may Allah have mercy on him) said: If he reads Qur’an from the Mus-haf, that does not invalidate his prayer, whether he has memorized it or not. Rather that is obligatory in his case if he has not memorized al-Faatihah, as noted above. If he turns over the pages sometimes whilst praying, that does not invalidate the prayer.
If he looks at anything written that is not Qur’an and reads it to himself, that does not invalidate his prayer, even if he does that at length, but it is makrooh (disliked). This was stated by ash-Shaafa‘i.
End quote from al-Majmoo‘ (4/95). See also: Rawdat at-Taalibeen (1/294).
Al-Mirdaawi said in al-Insaaf: The prayer is not invalidated by a lengthy looking at a book, if he reads it in his heart and does not move his lips, according to the correct view, which was deemed to be more correct in al-Furoo‘ and elsewhere. The author and others said: This is our view. It was narrated from Imam Ahmad that he did that.
And it was said that it does invalidate the prayer. This was stated by a number of our companions, including Ibn Haamid.
End quote (3/616).
Conclusion:
Prayer is not invalidated by looking in a Mus-haf in which there is commentary on Qur’an, and the like, on condition that the worshipper does not move his lips when reading anything except Qur’an. Rather, if he looks at the meaning and thinks of it, there is nothing wrong with that, if he needs to do it.
However, what he should do is to avoid all of that completely, and when he is praying behind an imam, he should be content with listening attentively to his imam and following his recitation. If he is leading the prayer or is praying alone, he should recite to himself whatever he can, and he should not let himself be distracted by anything except reciting Qur’an and doing the actions of the prayer, because prayer should be his focus and preoccupation, as the Prophet (blessings and peace of Allah be upon him) said.
See also the answers to questions no. 9505 and 125619.
And Allah knows best.