But the Lord was with Joseph and showed him steadfast love and gave him favor in the sight of the keeper of the prison.” (Genesis 39:21, ESV)

I’m guessing that Joseph did not feel that God was with him, indeed I’m guessing that Joseph thought just the opposite: that God had abandoned him.

Think of the process Joseph has been through.  He’s been falsely accused of a heinous crime against his employer.  He was already a slave and now he is a slave who is in prison on false charges which he can never disprove.  Surely his fate will be to rot away in prison forever because there is no one in Egypt who has the least concern that he is in prison, or that he has been falsely accused…”But the Lord was with Joseph.”

Despite all evidence to the contrary, the reader is told that all of this was the Lord being with Joseph.  Joseph could not have known that after being in prison for awhile, he would be suddenly freed and elevated to the second highest position in Egypt, that he would be given a Egyptian wife, and that the Lord had selected him to rescue his own family from death by starvation.

Sometimes the Lord being with us is not going to look as if he is with us, indeed it may look exactly the opposite of what we might expect.  This seems to be the way that the Lord works.