Another subject, Jared, had a similar theory. “When you’re out in the world, you can be wearing grubbies, and you’ll be perceived a certain way if you’re black,” he said. He told me he imagined white people operated under a different public dress code: “If you have money, it’s O.K. to wear rags.”

Michael, a corporate manager, reported that he asserted his class status at work by refusing to answer his own telephone, always allowing calls to go through to his receptionist. He believed that taking on administrative tasks would reduce his social status in the workplace to that of a subordinate and leave room for his colleagues to see his race before his class and treat him with less respect.

The people I spoke to said they paid a price when they failed to perform these public identities. Once, dressed in sweatpants and a baseball cap, one of my subjects, Lydia, decided to view a model home. Right away, the real estate agent asked if the house was in her price range. Lydia knew that preapproval was not required for a tour and suspected that, because of her casual clothing combined with her race, the agent had mistaken her for a poor person who couldn’t realistically make an offer. After learning the asking price, which was in her range, Lydia took charge of the interaction, putting on a public identity in the form of demonstrating assertiveness and knowledge of the market. “Basically, I told her I’ll take a look at the house and I’ll let her know when I’m finished,” she explained. And she did.

Lydia’s experience echoed those of other house-hunting middle-class blacks who told me that they relied on firm language and knowledge of the market to manage interactions with white realty agents, hopeful that if they conveyed that they were informed and authoritative, they would be seen as members of the middle class and treated with respect.

Lydia wanted a home with a fireplace and she got it. However, she and other middle-class blacks I spoke to had no way to systematically assess how their housing searches compared with those of their white counterparts. While these interviews took place some time ago, and much has changed in the country since, black people have just as much reason to worry today. Decennial audit studies conducted by the Department of Housing and Urban Development, as well as an investigation conducted on Long Island and published by Newsday in 2019 (in which black and white trained testers using comparable financial identities visited the same real estate offices) have uncovered overwhelming evidence of housing discrimination against blacks, decades after the Fair Housing Act of 1968 made the practice illegal.

The people I talked to tended to focus more on their success in managing public interactions than they did on what these efforts cost them in time, energy and emotions. But engaging public identities exacts a psychological toll, as one study participant hinted when she described “a relaxed day” at work for her as one during which she didn’t have to care what white people thought. And it’s worth mentioning that while my research focuses on middle-class black people, there’s no doubt that black people of lower socioeconomic status who can’t tap into these public identities have daily encounters that are even more unfair and demoralizing.

The humiliation that Ms. Gonzales says she endured at the hotel and that many endure every day cannot be resolved by anti-discrimination legislation alone. Racism and stereotypes persist alongside the desire of black people to be treated as well as whites — so the exhausting work of performing public identities will persist, too.

Karyn Lacy (@KarynLacy) is a professor of sociology at the University of Michigan and the author of “Blue-Chip Black: Race, Class, and Status in the New Black Middle Class.”

The Times is committed to publishing a diversity of letters to the editor. We’d like to hear what you think about this or any of our articles. Here are some tips. And here’s our email: letters@nytimes.com.

Follow The New York Times Opinion section on Facebook, Twitter (@NYTopinion) and Instagram.