I am at a bit of a loss as to what to do.
Back story: I was put on a project that was far behind and was very low developer quality adhering to no set of standards or practices. The project was not following the company's Standard Operating Procedures even the most essential like code reviews. I had begun communicating that in our messaging application to the team and kept trying to push for change in a positive way. Sadly, the team manager refused to listen was actively combative and would do the opposite or disagree for the sake of disagreeing with me, it was a rough scenario. I persevered and made changes to the standard where I could and the other developers came to rely on me and I was able to help them finish their sprint goals and aid them in their coding while doing my own and the improvements when time permitted. Later on another developer came onto the project as an architect and was able to tell the team manager to implement the changes I proposed.
Flash forward to yesterday. I have a review with our group manager, the team managers long time friend. I am told that my communication was distracting the other team members and I am responsible for sprint delays despite having a mountain of evidence to the contrary and the project being further when I joined. She, the group manager, had proceeded to tell me she had told this to upper management. When asked how my core job capacity was I was told everything was fine. When asked if she could point to a message that was distracting or non-constructive she would not. I was then told that all of the changes that I was able to get implemented thanks to the architect were all the architects credit. She was also unable to provide any means of improvement for my core job capacity.
Now I fully intend to tender my resignation, but I do not want to leave with upper management thinking that I was incompetent or the cause of them losing a few hundred thousand dollars. I have all the messages and I even have proof that the two managers were lying to upper management on the reason why some features were just ignore.
I do not know if I should go to HR with this first or email the department manager with examples show casing everyplace he has been lied to along with examples of my supposed negative communication. There's also a possibility of letting it go but that would leave a bad taste in my mouth along with a stain on my professional career which I am proud of.