Henry: I saw her ankles.
Captain Jack Sparrow: You would've seen a lot more if you kept your cakehole shut.
In the movie Jack gets the compass from his former captain when he is dying in the battle with Salazar. In the second film we saw that Jack got the compass from Tia Dalma/Calypso.
The ship we see Jack on in Salazar's flashback is called the Wicked Wench. This is a bit of an in-joke for PotC buffs, because that was the original name of the Black Pearl before being sunk by Cutler Beckett and raised again by Davy Jones. It's fully explained in a deleted scene of At World's End.