3 years ago I joined a company as a Software Engineer (after 3 years of work in tech industry) in a EU country and after 1 month of their required training I was assigned to a team that barely codes (or you can say doesn't code at all) I never liked that team, I was obliged to stay in that job because I needed money.
Later on I asked to move to an engineering team and I was doing quite well, but I left it because the team kept bullying me a lot because I am a foreigner (immigrant) they were very racists that they talk bad about me in their language while I am sitting with them not knowing that it was my 2nd language, and they kept on that bad behavior even after I told them that I speak their language. Also when it comes to code, they ignore my pull requests, questions...etc and never gave me a review for my code despite the fact that I kept asking for reviews constantly (TLDR; I was never welcomed in that team) I opened up to my managers about this problem but they didn't seem to care at all, it's like they take the side of employees by blood, if you're from the same country, speaking same language then you're always better/right.
This made me sick physically and mentally and I am now in a position where I cannot decide what to do, I need to save my technical knowledge and I want to find another job but I am afraid to fall in the same situation where people will treat me like a trainee just because I am a foreigner and an English speaker. I'd really love to resign and take some time for myself as I have much savings to get me through the next years, so I can heal myself from the "emotional damage" that has been done to me, but I still need to stay in this country because my goal here is to get citizenship (for a better future), and the only thing that can keep me here is a work contract.
What can I do in such a situation?