After me you will come under rulers who will be detained from saying prayer at its proper time by (their) works until its time has run out, so offer prayer at its proper time. A man asked him: Messenger of Allah, may I offer prayer with them? He replied: Yes, if you wish (to do so). Sufyan (another narrator through a different chain)said: May I offer prayer with them if I get it with them? He said: Yes, if you wish to do so.
قَالَ رَسُولُ اللَّهِ ﷺ إِنَّهَا سَتَكُونُ عَلَيْكُمْ بَعْدِي أُمَرَاءُ تَشْغَلُهُمْ أَشْيَاءُ عَنِ الصَّلاَةِ لِوَقْتِهَا حَتَّى يَذْهَبَ وَقْتُهَا فَصَلُّوا الصَّلاَةَ لِوَقْتِهَا فَقَالَ رَجُلٌ يَا رَسُولَ اللَّهِ أُصَلِّي مَعَهُمْ قَالَ نَعَمْ إِنْ شِئْتَ وَقَالَ سُفْيَانُ إِنْ أَدْرَكْتُهَا مَعَهُمْ أَأُصَلِّي مَعَهُمْ قَالَ نَعَمْ إِنْ شِئْتَ