I remember hearing that Potiphar's wife was a righteous woman. She had a vision showing her that she would become an ancestress of the Jewish people. She naturally assumed it would be through her directly, so she tried to seduce Joseph to make it happen. She did not think it might be through her daughter, who Joseph later married according to some accounts.
What is the source of this story?