I’ve ended up harmonizing it in my head by considering that God knows all things. He is beyond time and limits and so he knows every choice we will make.
So he knew Judas would betray Jesus. He did not force him to betray Jesus but since he knew Judas would he was able to foretell it.
So mankind , and all things, has free will and we make our choices, but our all knowing Creator already knows the future and so if he knows someone like the pharaoh would go back on his word he may harden or soften their heart so that’s they may choose a harder choice but even then it’s still them choosing and God is able to justify the hardening of the heart because he knows the choices they will make.
It’s something we can’t actually completely understand, but I believe we can get close enough to be at peace with how it works. Or at least that’s how I feel it happens with me.