He said, a man entered the mosque while the Messenger of Allah ﷺ was performing the morning prayer. He prayed two rak'ahs on the side of the mosque, then joined the Messenger of Allah ﷺ in prayer. When the Messenger of Allah ﷺ said the closing salam, he said, "So-and-so, which of the two prayers did you count, your prayer alone or your prayer with us?"
قال دخل رجل المسجد، ورسول الله ﷺ في صلاة الغداة، فصلى ركعتين في جانب المسجد، ثم دخل مع رسول الله ﷺ، فلما سلم رسول الله ﷺ قال: يا فلان بأي الصلاتين اعتدت، بصلاتك وحدك، أم بصلاتك معنا؟
Muslim reported it in Salat al-Musafirin (712) via Asim al-Ahwal, from Abdullah bin Sarjas, who mentioned the same.