For the repurposing, I would look for an experienced local architect. It is often less about regulations and more about political/administrative goodwill. The better this is prepared and justified, and if the architect ideally has a good connection to the person responsible, the greater your chances of getting it through without major pitfalls.
From personal experience:
Our landscape gardener owns an inherited farmstead in the rural area and had started to "illegally" set up 4 apartments there. When this came to light during the construction work, in addition to the corresponding payments, he was required to dismantle the apartments.
By chance, at a birthday party that weekend, he spoke to a well-established architect about it, who had the brilliant idea to offer the apartments to the city for housing asylum seekers and tie this to the condition of granting retroactive approval.
It worked.