TLDR - I was humiliated in my old workplace, I took a break and joined my dream company after multiple gruelling interviews, but I lack self confidence and keep getting flashbacks from my old workplace.
This is more of a mental health question tbh. I am a junior engineer, who started out with an internship and PPO in a good paying reputed bank straight out of a decent tier 1.5ish college. Throughout my life I feel I haven't worked consistently hard, in the sense I grind out in the last moment or somehow God saves me in the last moment for everything. In this company I had taken internal mobility around a year after joining due to personal reasons, and I hit it off really badly with my manager and this SDE 2 who also joined slightly after me but seemed to be favoured for everything, like if he asked any doubts my manager would explain very well, for me it depended on her mood but mostly she'd take digs at my intelligence. Within 2-3 months of joining this team I realised I made a bad decision, in fact other seniors in the team as well were like bro why did you join this team, we are only trying to leave, all the good people have left, etc.
My manager constantly berated me, said she'd never seen anyone as dumb as me, purposely used to delay reviewing my MRs, this SDE2 would nitpick and suggest random variable name changed and honestly me and a few other juniors also felt he didn't really understand stuff (cuz well he was also new) but used to suck up to my manager well. Everytime she gave me a task she would say I can't break it down more for you, during stand ups she'd interrupt me and publicly scream at me for minor slip ups or for just executing stuff she/SDE2 would have told me to do, shed say words went in one ear and came out the other. She'd often WFH or leave office early to spend time with her kids and give instructions through phone call and hated it if I asked something over teams or wanted to document something for confirmation. I feel all this is because we had some upper management changes and her manager used to publicly berate her and scream at her and even use curse words at her for doing wfh so much or not being efficient, and honestly she used to cause a lot of prod issues due to miscommunication with other teams, and this frustration was just trickling down at me.
I also believe I could have handled this better, after a few months I couldn't take it and I was in tears often and she used to mock me saying should I also go cry on the washroom when someone scolds me. I just lost it at some point, confronted her in a 1:1 saying I deserve basic human dignity, everyone does, why this favouritism, and that I read the news about the company doing layoffs and know for sure she's given my name. She was all like I believe in karma, I'll never lay anyone off since it will affect me on my life somehow, it's a horrible feeling and she started gaslighting me saying I don't respect her and made fun of me for crying. I feel I shouldn't have fought and should have stfu and kept myself calm but idk at that moment I just couldn't take it any more.
I admit I wasn't one of the best performers, in the sense the first 1/2 months she gave me a project which I could have done or at least presented more efficiently, but post that I tried quite hard, I was trying to switch but at the same time I was trying cuz ofc these projects would go on my resume and id have to explain in interviews. But for sure I wasn't a low performer, I just feel I couldn't defend myself well enough, in fact my old team gave me a very good review but this lady said it's too premature to consider these aspects and wrote her own stuff.
I was trying very hard to leave, eventually I did get laid off so tbh it was a blessing for me since I got more time to prepare and now I am in one of my dream companies with a great hike. I got multiple calls as well but was very selective while interviewing because I have runway and really wanted to focus on my mental health. But while laying me off my skip also abused me and said consider a different career, everyone is good at something, even if you go to another company I don't think you can handle technical stuff and all this.
I know I'm not supposed to take this personally, but honestly even now during standups I keep getting flashbacks of my old standups, the way I was treated. I am very religious and spiritual so it has helped me recover to a good extent but I'm still not able to forget the past, and I'm scared that I'll get insulted and laid off in my new company too. My family and friends say first of all layoffs are very common these days, on top of that the old company is very famous for toxic culture and the new company is very famous for excellent sde practices and good culture, afterall I did do decently academically, did decent in JEE which is why I got a decent college and my old team members also were in touch and said such toxic things have happened to their friends as well, but they bounced back strong.
During my break I started gymming, meditating, visiting lots of temples for peace. I also bought a couple of famous books for distributed systems and in general systems programming but haven't been able to finish them. I realised I got into this field for the love of computer science since high school, nobody forced me and I got good dopamine hits doing problems on CF and leetcode. But as soon as I entered corporate that fear and shame is still there. Do any of you have any suggestions to stop having suck negative thoughts, just focus on my current work positively and in general just regain confidence. It's not the layoff that affects me, it's the public humiliation and attack on my intelligence and character that does.