Two of Pharaoh's highest ranking officials are thrown in prison for an unknown crime, where Joseph happens to be serving time. Both officials have a dream on the same night and thankfully Joseph is there to provide an interpretation. This provides some important setup for what will come next.
Sources:
Guzik, D. (2018). Genesis 40 - Joseph Interprets Dreams In Prison. Enduring Word. https://enduringword.com/bible-commentary/genesis-40/
Wiersbe, W. W. (2010). Be Authentic (Genesis 25-50): Exhibiting Real Faith in the Real World. David C. Cook.