*bangs head on desk*
Answer to this: Do NOT rent a property to anyone prior to selling it, and make sure your lawyer puts together an iron clad deal with no conditions that favor the buyer in odd ways. Do your due diligence in making sure there’s nothing out there that could jack-up the sale.
If you have squatters, the law is an ass, and a slow one at that. Good luck with that.