The last six years have not been easy for Wells Fargo (WFC -0.26%) since the bank's phony-accounts scandal came to light in 2016, in which employees at the bank opened millions of depository and credit card accounts without the consent of their customers.

As a result, the bank has paid billions of dollars in fines, lost billions in potential profits, dealt with numerous consent orders from regulators, had a crippling asset cap that prevents the bank from growing its balance sheet, and experienced a lot of turnover among management and the board of directors.

But even after all these years, the phony-accounts scandal and other past issues continue to plague the bank. Despite these significant headwinds, I still think the company is headed in the right direction, and therefore, I like the stock. Here's why.

Charges from past scandals

Wells Fargo recently produced solid third-quarter results that beat analyst expectations, as the bank benefited from continued strong credit quality and the higher-interest-rate environment. But baked into its earnings results was a $2 billion charge, or $0.45 impact to earnings, due to "accruals primarily related to a variety of historical matters, including litigation, customer remediation, and regulatory matters."

Person standing outside looking at sun.

Image source: Getty Images.

Management on the bank's earnings call didn't provide a ton of detail as to which regulatory matter this might be related to, but we know Wells Fargo has many outstanding consent orders, and I think there is a good chance this could be related to the phony-accounts scandal.

Wells Fargo has been dealing with these accruals for some time, but this particular one in Q3 is so much bigger than in the recent past. Wells Fargo places these accruals under a non-interest expense category called operating losses. In Q3, operating losses swelled to more than $2.2 billion. In the prior four quarters, operating losses had not exceeded $673 million.

Furthermore, CEO Charlie Scharf told analysts and investors that this would not be the last of the charges. "And we said, I think likely, highly likely that we will have more significant -- potentially significant losses related to some of these historical matters. So we just want that to be on the radar screen."

The company continues to make progress

It's unfortunate to keep seeing these charges roll in and even more unfortunate to hear that they are likely going to continue. The fact of the matter is that nobody knows how long it will take until these matters are fully behind the bank.

But the silver lining here is that Wells Fargo's core business continues to look better and better. The higher-interest-rate environment is significantly boosting the amount of money the bank generates on its loans and bond holdings, and credit quality remains pristine -- for now. 

Furthermore, management continues to execute well on its efficiency initiatives. Core expenses are down more than 5% year over year. The bank has also decreased employees by 6%, professional services like consultants by 10%, and occupancy expenses by 4%. The bank is on track to eventually reduce annual operating expenses by $10 billion from when it started the program in early 2021.

Scharf has also been ramping up other businesses like credit card lending and investment banking that can boost profitability on more of a long-term basis.

But even if you look at core profitability right now, the bank continues to make meaningful progress toward Scharf's medium-term goal of achieving a sustainable 15% return on average tangible common equity (ROTCE). The bank generated an ROTCE of 9.6% in Q3. But without that $2 billion charge discussed above, my rough estimate is that Wells Fargo would have generated an ROTCE in the quarter in excess of 14%.

The stock is a buy

Despite continuing regulatory headwinds, Wells Fargo's core business continues to improve, and Scharf seems to have the bank headed in the right direction and well on its way toward a 15% sustainable ROTCE, which could just be the beginning.

It may still take several years, but I do believe Wells Fargo will eventually be able to put its regulatory troubles in the rearview, not that I have any idea when, because the timeline has already lasted longer than I once thought.

While we are in difficult market conditions that may keep the stock more depressed in the near term, the bank trades around 134% to its tangible book value, or net worth, and at 10.75 times forward earnings. Both of those metrics leave room for long-term upside in the share price.