The Messenger of Allah ﷺ said, "You will likely live to see people who pray the prayer outside of its proper time. If you encounter them, then pray in your homes at the time you know to be correct, then pray with them and treat that prayer as a voluntary one."
حدثنا محمد بن الصباح أنبأنا أبو بكر بن عياش عن عاصم عن زر
قال رسول الله ﷺ لعلكم ستدركون أقواما يصلون الصلاة لغير وقتها فإن أدركتموهم فصلوا في بيوتكم للوقت الذي تعرفون ثم صلوا معهم واجعلوها سبحة
[Sahih] Reported by Nasai, 2/75, 76, Book of Imamah, Chapter on Prayer with Unjust Leaders, no. 780, from the hadith of Abu Bakr through this route. Ibn Khuzayma graded it sahih, no. 1640, and see no. 855 for its underlying issue. The hadith has many corroborating narrations, including one in Muslim, no. 648, and others.