Yahya related to me from Malik from Sumayy, the mawla of Abu Bakr, from Abu Salih as-Samman from Abu Hurayra that the Messenger of Allah ﷺ said, "When the imam says, 'Allah hears whoever praises Him,' say 'O Allah! Our Lord, praise be toYou, 'for the previous wrong actions done by the one whose utterance coincides with that of the angels are forgiven."
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِذَا قَالَ الإِمَامُ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ فَقُولُوا اللَّهُمَّ رَبَّنَا لَكَ الْحَمْدُ فَإِنَّهُ مَنْ وَافَقَ قَوْلُهُ قَوْلَ الْمَلاَئِكَةِ غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ