The Zohar tells us that we must learn from Joseph.

When he fell into his brothers’ hands, they almost murdered him and they sold him into slavery.

But when his brothers fell into his hands, he brought them to repent, and then arranged for them the best living conditions in Egypt.

Joseph was a tzadik. He had mastered the beast within his heart.

But the Zohar speaks to us, and tells us, “Even when your heart burns with fury at those you envy or despise, or have wronged you, even at the time that your mind is assaulted with thoughts of spite and revenge—

—even then, you have the power to do the polar opposite of what the beast within you demands you do, to refuse to entertain those nasty thoughts or to express any anger, and instead to deal with these people with respect and even greater kindness to the opposite extreme.

In a way, that may be greater than a tzadik such as Joseph. For you have defeated the beast at the zenith of its power.

Tanya, end of chapter 12. See also chapter 27.