You might like this answer relating game theory & the social contract: Is the tyrannicide perpetrated by William Tell morally legitimate?
Indirectly relevant might be this discussion of wisdom as our dilemma-solving faculty, which depends on a practice of discovering the integrated centre of our concerns: Wisdom and John Vervaeke's awakening from the meaning crises?
There are many reasons to continue aid work in countries with despotic leaders & corruption. Charities are scrutinised on this, & have clear policies to prevent issues & manage conflicts of interest. Effective Altruism is a framework advocated by philosopher Peter Singer, but it doesn't as far as I know have specific answers on these issues, & is widely criticised in practice. Many people who oppose fossil fuels, the arms trade etc, don't check where their pensions are invested, & that's how those industries are financed, systematically thinking about choices like that is at least as important.
The paradigmatic case for decision making on difficult choices about staying & cooperating or leaving & opposing, is Nazi collaboration. If you look at war crimes trials, they distinguish between what people were ordered to do, & chose or volunteered to do, & this applies when working with a bad regime - the real danger I think is choosing to do or avoid things because it would cause 'trouble', or might create some problem you can't be sure about, & consequences aren't clear-cut. It comes down to integrity, & conscience.
Sartre dealt explicitly with some of the issues, in The Republic Of Silence, short book Existentialism Is A Humanism, & play No Exit. Well worth reading. He has been criticised by later writers, but not by other resistance fighters & compatriots who lived through those times.
Philosophy around non-violence & non-cooperation is interesting, like the research on a century of protests that Extinction Rebellion base their strategy on, mentioned here. A solid case can be made that to be really effective, there has to be a fear on the part of government about escalation - exactly why, I suggest is highly local & specific involving given circumstances, & certainly isn't limited to realistic threat of violence. But learning about past struggles in depth is one of the most useful things to do. Indian Independence, ending South African Apartheid, US Civil Rights. And now Hong Kong & many other places. It's not a binary of collaborate or leave.
I'd suggest you've already made it pretty clear you lean towards staying, leaving & starting from scratch is a bit of a 'nuclear option'. All the more reason though to clarify for yourself what events would push you to that, & to know how you would - repercussions for truly doing the best good you can, could force you to leave, & feeling you can't or aren't ready might stop you doing good. You have implicit knowledge of the place you are & networks there, surely it is exactly where things are difficult that the most good can be done - finding the places injustice can be pushed against.
I feel this is more, an issue for reading people's real stories, & for absorbing literature, than for philosophy. The complex balance of when & how to do good, what risks to take knowing who they might impact, come down to deeply personal choices, that express an individual, moment by moment. I found 'The Unbearable Lightness Of Being' a really powerful meditation on compromise, choices & expression of identity.