No envy except in two
لَا حَسَدَ إِلَّا فِي اثْنَتَيْنِ: رَجُلٌ آتَاهُ اللَّهُ مَالًا فَسُلِّطَ عَلَى هَلَكَتِهِ فِي الْحَقِّ، وَرَجُلٌ آتَاهُ اللَّهُ الْحِكْمَةَ فَهُوَ يَقْضِي بِهَا وَيُعَلِّمُهَا
La hasada illa fi-thnatayn: rajulun atahu-llahu malan fa-sullita ala halaketihi fi-l-haqq, wa rajulun atahu-llahu-l-hikmata fa-huwa yaqdi biha wa yu'allimuha.
"No envy except in two: a man whom Allah has given wealth and the power to spend it on what is right, and a man whom Allah has given wisdom by which he judges and teaches."
Narrated by Abdullah ibn Mas'ud. Sahih al-Bukhari 73, Sahih Muslim 816
A short reflection
The word here is ghibtah, not hasad. Not wishing the blessing taken from him, but wishing the same upon yourself. Envy of the act, not the person.