((Imām Bukhārī narrates) that) Humaidī narrated to us, he said: Sufyān narrated to us, he said: Ismā'īl ibn Abī Khālid narrated to me — apart from this, Zuhrī narrated to us, he said: I heard Qais ibn Abī Hāzim, he said: I heard 'Abdullāh ibn Mas'ūd, may Allāh be pleased with him, saying that the Prophet ﷺ said:
Hasad (ghibtah) should be done only regarding two persons: one, a person to whom Allāh has given wealth, and he spends it in the rightful channels; the other, a person to whom Allāh has given wisdom, and he judges according to this wisdom (knowledge) and teaches it to the people.
Reference: Sahih Al Bukhari 73