He was the same man in the cell and on the throne
The men locked up with him had no idea he would ever be anything. He was another prisoner. They still came to him and said: “we see you as one of those who do good” (12:36).
Watch where that word follows him. The Quran uses it for him as a young man in the house of a stranger (12:22), for him in prison (12:36), and again once he has been put in charge of Egypt (12:56). Three completely different lives. Same description.
That word is ihsan. It means doing something properly whether or not anyone watching is in a position to reward you for it. Nothing about how Yusuf treated people shifted when his circumstances shifted. Not when he lost everything, and not when he got back more than he lost.