The Messenger of Allah ﷺ said, "They lead you in prayer. If they get it right, the reward is for you and for them, and if they err, the reward is still for you and the burden is upon them."
حدثنا حسن حدثنا عبد الرحمن بن عبد الله بن دينار عن زيد بن أسلم عن عطاء بن يسار
قال رسول الله ﷺ يصلون بكم فإن أصابوا فلكم ولهم وإن أخطئوا فلكم وعليهم
Its isnad is sahih. Bukhari related it in 1/178, in the book of adhan, chapter of "When the imam does not complete." The plural pronoun refers to the imams whom the people are not pleased with, as will be made clear by another narration coming later.