Terminating expatriate after expiry of permit

I am an expatriate working in Tanzania for 5 years now having signed a 10 year contract of employment with my employer which would expire in 2021. My work permit expired few months ago and last week I was given a termination letter by our HR Manager on the grounds that the application for renewal of my work permit was refused by the Commissioner for Labour. I have not been paid any terminal benefits. Is this fair under Tanzanian labour laws? Please guide me.
AS, Morogoro

Where an expatriate is found working without a valid work permit, both the expatriate and the employer are committing a crime under section 9 of the Non-Citizens (Employment Regulation) Act, 2015. Expiration of a work permit automatically makes the contract of employment with an expatriate unenforceable because an expatriate cannot work without a work permit. Since the refusal to renew the work permit automatically renders an employment contract with a local employer unenforceable, an expatriate whose work permit expires and is refused renewal by the Commissioner for Labour cannot fault a local employer for breach of contract and claim any compensation for unfair termination.

However, an expatriate whose contract of service is automatically terminated for expiration of a work permit is entitled to a repatriation allowance to the place of recruitment if he was recruited from overseas. He is also entitled to a payment for the work done up to the date of termination, severance pay and unused leave pay as well as notice pay. Only compensation for unfair termination he/she cannot claim.