I found another solution that may be related to the distance problem, in my case there were so many settlements that I simply don't know which one was giving the distance problem.
I managed to solve it, although being honest it's a bit messy and I'm looking for a more optimal solution.
In my case the error came from a bug in the DefaultMapDistanceModel script in the GetDistance function inside the dll TaleWorlds.CampaignSystem, which caused one of the settlements to come to null and crashed the game.
Putting that if the settlement is null return the maximum distance resolved the error.
To apply this change you will need to modify the TaleWorlds.CampaignSystem dll library, which I recommend you do with extreme caution.