Messenger of Allah ﷺ said, "When the Imam says, "Samiʿa l-lahu liman hamidah," you should say, "Allahumma Rabbana laka l-hamd." And if the saying of any one of you coincides with that of the angels, all his past sins will be forgiven."
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِذَا قَالَ الإِمَامُ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ فَقُولُوا اللَّهُمَّ رَبَّنَا لَكَ الْحَمْدُ فَإِنَّهُ مَنْ وَافَقَ قَوْلُهُ قَوْلَ الْمَلاَئِكَةِ غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ