Ubayd Allah ibn Maʿmar, who reported that the Messenger of Allah, peace and blessings be upon him, said this. Al-Ṭabarānī does not include the final phrase.
I say: This is an authentic chain of transmission. Its narrators are trustworthy and are all among Muslim’s narrators, apart from Ibrāhīm ibn al-Ḥajjāj al-Sāmī—with an unpointed sīn—who is trustworthy. Al-Haythamī said (8/19): “Al-Ṭabarānī narrated it, and its narrators are those of the Ṣaḥīḥ, apart from Ibrāhīm ibn al-Ḥajjāj al-Sāmī, who is trustworthy.”
The hadith has a corroborating report from the hadith of ʿĀʾishah, may Allah be pleased with her, attributed to the Prophet: “Whenever Allah intends gentleness for the members of a household, He benefits them by it; and whenever He deprives them of it, He harms them.” Al-Bayhaqī narrated it in Shuʿab al-Īmān, as cited in al-Mishkāt (5103).