Abu Sa'id al-Khudri (may Allah be pleased with him) said that in the time of the Prophet (peace and blessings be upon him) some hypocrites would do this: when he went out on a campaign, they would stay behind and rejoice at sitting back in opposition to the Prophet (peace and blessings be upon him); and when the Messenger of Allah (peace and blessings be upon him) returned, they would make excuses, swear oaths and want the Messenger of Allah to praise them for what they had not done. So this verse was revealed about them: "Do not think that those who rejoice in what they have done and love to be praised for what they have not done, do not think them safe from the punishment; and for them is a painful punishment." [Surah Al Imran: 188]
Imam al-Shafi'i (may Allah have mercy on him) said: Allah, the Mighty and Majestic, disclosed their secrets to His Messenger (peace and blessings be upon him), and also disclosed the news of those who listened to them and followed them, and their wish to put his companions to trial by resorting to lies, by spreading alarming rumours, and by inciting his companions to withdraw their support from him. And Allah informed that He disliked their setting out with this intention. This is proof that Allah has commanded that whoever becomes known for this should not be allowed to take part in the campaigns of the Muslims, because there is no harm to the Muslims (in keeping them out). Then this is further emphasised by His saying: "Those who stayed behind rejoiced in their sitting back in opposition to the Messenger of Allah." [Surah al-Tawbah: 81] He recited up to: "So sit with those who stay behind." [Surah al-Tawbah: 83]
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 17872