Added 28 minutes later
I tested it a bit. To get this "prison" thing to happen in the campaign, the hero who is in prison in a specific scenario must be the one who transitions to that scenario. I opened the prison with Mefala, in which Mefala was supposed to be, and I got exactly this message: "The jailer informs you that the prisoner who was held in this dungeon has been released by order of the king who imprisoned him."