AI on moving platform (like a ship deck)

I want to have AI (enemies) on a boat that moves on a path around the level (an island).
But the AI seems to have a problem navigating on the deck of the ship. They always end up on the far back of the deck (they move with the ship, but it seems the target location of their movement is always lagging behind the boat, so they always end up on the back end of the deck).
The navmesh is set to dynamically rebuild, but that doesn’t seem to be enough.

I’ve read on other forums that you could create a copy of the ship that is hidden somewhere not visible and doesn’t move, and use that to calculate the navmesh and the movement of the characters and then use the results to move the AI on the actual moving ship, but I don’t know how to even start doing that. How do I tell the AI to use the unmoving boat to calculate the movement, and how do I ‘translate’ it back to the moving boat?