Walmart has boosted wages, set ambitious sustainability goals and is pledging to promote more women into senior leadership — but Americans are still souring on the iconic brand.

While the retailer’s sales have improved thanks to less-cluttered aisles and a push into e-commerce, its image is lagging. After a recent peak in 2016, when the company said it would invest billions in stores and online to win back customers, public perception has declined for two straight years, according to the Reputation Institute, a research and advisory firm.

“Doing the right thing is one thing,” said Stephen Hahn-Griffiths, chief reputation officer at the institute, referring to Walmart’s worsening numbers. “Getting the credit for it is another.”

The group’s latest survey on Walmart was conducted before the news that migrant children are being housed in a Texas detention center that…