You have to make sure your shoes/sandals are clean before praying in them
28 May 2023 • 2.0K views

Narrated Abu Sa'eed Al-Khudri radhiyallahu anhu: While the Messenger of Allah (ﷺ) was leading his Companions in prayer, he took off his sandals and laid them on his left side; so when the people saw this, they removed their sandals. When the Messenger of Allah (ﷺ) finished his prayer, he asked: What made you remove your sandals? They replied: We saw you remove your sandals, so we removed our sandals. The Messenger of Allah (ﷺ) then said: Jibreel came to me and informed me that there was filth in them. He then said:
((إِذَا جَاءَ أَحَدُكُمْ إِلَى الْمَسْجِدِ فَلْيَنْظُرْ فَإِنْ رَأَى فِي نَعْلَيْهِ قَذَرًا أَوْ أَذًى فَلْيَمْسَحْهُ وَلْيُصَلِّ فِيهِمَا))
“When any of you comes to the masjid, he should see; if he finds filth on his sandals, he should wipe it off and pray in them.” [Sunan Abi Dawud, 650 - graded 'Saheeh' by Sheikh Albani]