Anas, may Allah be pleased with him, was asked whether the prophet ﷺ used to pray in his shoes? He said: Yes. [Al Bukhari]. Ibn Hajar said in “Fath Al Bari” Ibn Battal said: It is allowed if there is no impurity on them, it is permissible and not from what is preferred, because this does not become one of the necessities for prayer. It is from the clothing that is considered an adornment, As Allah SWA means in the verse: (Oh children of Adam, beautify yourselves for every act of worship) except if the earth that you have walked on had a lot of impurities, then it may fall short of this rank. If there is conflict between observing the command of beautifying oneself, and observing the removal of impurity, the second overrules, because it falls under the category of prevention of the evil, while the earlier is treated under the category of bringing benefit. Unless if an evidence is presented that puts beautifying under the acquiring benefit, then it is referred to and this view is dropped.
Ibn Hajar said after quoting the words of Ibn Battal: Abu Dawoud and Al Haakim narrated in a hadith of Shadaad bin Aws: (Act differently from the Jews, for they do not pray in their sandals or their shoes.) The preference of this act was recommended only to differ from the Jews, as mentioned in the hadith. Though, there is a very weak hadith regarding the praying in shoes and considers it as the adornment that is commanded by the verse. [Fath Al Bari volume 2 page 41].
From this we can conclude that praying in shoes is not allowed if they are unclean, if they are clean then there is nothing stopping one from praying in them. This is only permissible and not recommended as an act of worship, because there is no correct evidence that justifies such. It is better to off the shoes or sandals if the mosque is furnished with a clean carpet, so that you keep it clean from dirt even if the shoes are clean-pure, as well as observing the customs, which is good if it is supported by the religion. Praying in shoes is different from praying in socks (khuf) which have been wiped over, for that is allowed and has its own conditions, including purity.