What does Genesis 40:4 mean?
The captain of the guard assigned Joseph to look after them, and he served them while they were in custody for a while. Genesis 40:4 - Modern Text Bible
(Joseph is put in charge of these two officials, giving him a chance to interact with them.)