The Messenger of Allah ﷺ said, "When the imam says, 'Allah hears the one who praises Him,' say, 'O Allah, our Lord, to You belongs all praise.' For whoever's words coincide with the words of the angels will be forgiven his past sins."
و حدثني عن مالك عن سمي مولى أبي بكر عن أبي صالح السمان
أن رسول الله ﷺ قال إذا قال الإمام سمع الله لمن حمده فقولوا اللهم ربنا لك الحمد فإنه من وافق قوله قول الملائكة غفر له ما تقدم من ذنبه