Don’t confuse righteousness with self-righteousness.
There is a difference between being morally justified and believing oneself to be superior to all other because of it. Most times a self-righteous person will be a hypocrite because they believe they are perfect and without fault due to their morality.
“Believing oneself to be perfect is often the sign of a delusional mind.” Data/ Star Trek
For I have come to call not those who think they are righteous, but those who know they are sinners. -Jesus