Praise be to Allah.
It is not permissible for a Muslim to offer an obligatory prayer on his mount, unless there is a valid excuse, because on a mount he will omit some of the essential parts of the prayer, such as standing, bowing and prostrating.
It was narrated from Jaabir ibn ‘Abdullah (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) used to pray on his mount facing towards the east, but when he wanted to offer an obligatory prayer, he would dismount and face towards the qiblah.
Ibn Battaal said: The scholars are unanimously agreed that it is not permissible for anyone to offer the obligatory prayer on his mount without a valid excuse. Because offering obligatory prayers on one’s mount when it is possible to dismount is not permissible, and because the conditions of the obligatory prayer stipulate that the worshipper should face towards the qiblah and continue to do so throughout, an obligatory prayer offered by a rider who cannot stand up or face the qiblah is not valid.
End quote from al-Mawsoo‘ah al-Fiqhiyyah, 27/231
But this ruling does not apply to one who prays on a bus when he is able to do all the obligatory and essential parts of the prayer, such as facing towards the qiblah, standing, bowing and prostrating. The scholars have stated that praying in a howdah is valid, because one can do all the obligatory parts of the prayer. The howdah is like a room on the camel’s back.
An-Nawawi (may Allah have mercy on him) said: The conditions of the obligatory prayer are that the worshipper should face towards the qiblah and continue to do so throughout. It is not valid without facing towards the qiblah except in cases of extreme fear, and it is not valid on the part of one who is walking whilst facing towards the qiblah, or one who is riding and is not able to stand up or face towards the qiblah. And there is no difference of scholarly opinion on this point.
If he faces towards the qiblah and does all the essential parts of the prayer in the howdah or similar place on the back of a mount that is standing, there are two opinions concerning the validity of his obligatory prayer. The more correct opinion is that it is valid and this was stated definitively by the majority.
End quote from Sharh al-Muhadhdhab, 3/221
It says in al-Mawsoo‘ah al-Fiqhiyyah (27/231): If the obligatory prayer is offered on one’s mount, that is not permissible unless there is an excuse, because the conditions of the obligatory prayer are that the worshipper should be facing towards the qiblah and continue to do so throughout, and he should fulfil all the conditions and essential parts. But if a person is able to offer the obligatory prayer atop his mount, fulfilling all of its conditions and doing all of its essential parts, even if he has no excuse, his prayer is valid. This is the view of the Shaafa‘is and Hanbalis, and it is the preferred view of the Maalikis.
Based on that, there is nothing wrong with you praying on the bus so long as you do all the essential parts of the prayer.
But it must be noted that it is obligatory to offer the obligatory prayer with the Muslim congregation in the houses of Allah (i.e., in the mosques) and it is not permissible to stay away from offering the prayer in congregation in the mosque except for one who has an excuse. For more information please see the answer to question no. 8918 and 40299.
And Allah knows best.