The Prophet ﷺ said, "Pray the prayer at its proper time. If you then find the imam leading the people in prayer, pray with them, for you will have already secured your prayer, and this second one will count as a voluntary prayer for you."
حدثنا محمد بن بشار حدثنا محمد بن جعفر حدثنا شعبة عن أبي عمران الجوني عن عبد الله بن الصامت
عن النبي ﷺ قال صل الصلاة لوقتها فإن أدركت الإمام يصلي بهم فصل معهم وقد أحرزت صلاتك وإلا فهي نافلة لك