Want to know a sure way to be seen as immoral, unethical and unlikable? Raise $1 million for charity. Want to know how to have people think a lot more favorably of you? Raise nothing at all. If you think that’s entirely irrational, you’re right. Welcome to the human condition.

The key to being thought of as a louse for helping the sick or the poor is not the act of giving by itself, but the act of benefiting from it. That million dollars looks a little less princely if, for your troubles, you kept 10% of it—even if you made that intention clear from the start and even if $900,000 still went to the folks who need it most. Fork it all over or don’t expect any applause.

The idea that a good act doesn’t count if the actor benefits as well is known as “tainted altruism,” and it not only makes little sense, it can also cause real harm, as professors of organizational behavior George Newman and Daylain Cain of Yale University prove in a study in this month’s issue of Psychological Science. But there are ways around the problem, the investigators show, ones that reflect a subtler understanding of just what morality is—and which may help boost charitable giving too.

(MORE: Driving Over Your Best Friend: It’s the Right Thing to Do)

Newman and Cain cite the cautionary tale of Daniel Pallotta, former head of a for-profit company that raised money for AIDS research and other causes, and over the course nine years, generated a whopping $305 million in donations. As head of the company, he earned $400,000 per year. That fact was not widely known, but once it was made public, he was hit with a storm of criticism and his company went out of business. In a 2008 article in the New York Times titled, “The Sin of Doing Good Deeds,” columnist Nicholas Kristof reported that revenues from a single charitable fundraiser dropped from $71 million when Pallotta was in charge to just $11 million after. So who’s immoral now—Pallotta or his critics?

To test how real the tainted altruism phenomenon is and how it might be corrected, Newman and Cain devised four experiments. In the first, subjects were offered two scenarios in which a man hoping to impress a woman offered to do volunteer work at her place of business. In one version, she worked at a coffee shop; in the other, at a homeless shelter. Some subjects read one version, some read the other and a third group read both. All of them were asked to rate, on a scale of 1 to 9, how much they liked the man and how moral and ethical they thought he was. They were also asked how much his actions benefited society.

Remarkably, the people who read the homeless shelter scenario rated the man as less moral—4.75 out of 9.00—than the people who read the coffee shop scenario, who gave him a 5.62. What’s more, they rated the benefit of his work to society as pretty much equal in both cases. Only the group that had read both scenarios—and thus had a chance to compare the kinds of good that were being done—had a more balanced view of things, with the man being seen as equally moral in both cases and doing much greater good, with a 6.46 score, in the homeless shelter than in the coffee shop (4.67).

“To some extent,” Newman and Cain wrote, “participants recognized the inconsistency of doing some good as worse than doing no good at all.”

(MORE: The Most Important Brain in the History of Neuroscience)

In the second experiment, subjects were presented with what was essentially the Pallotta dilemma. Some were asked to choose between two for-profit fundraisers to manage a charitable event—one who raised $1 million for the charity and was paid a flat fee of $10,000; and another, named “Daniel P.” who raised $1.1 million and was paid 5% of the take, in this case $55,000—a bigger haul for both the charity and himself. Other subjects in the group read the same scenario, except in this case the funds were being raised for a profit-making start-up rather than for a charity.

In both cases, subjects chose the flat-rate fundraiser over Daniel P., even though that meant less money for their ultimate cause. When the exact dollar amounts were manipulated to determine how much the subjects would be willing to forgo to avoid hiring Daniel P., the results were eye-popping, with $59,900 getting left on the table for the start-up and a whopping $173,470 for the charity. “Self-interest not only taints evaluations of prosocial efforts, the authors wrote, “but also can change the decisions people are willing to make regarding them.”

The third and fourth experiments presented the subjects with two situations in which a business owner wanted to raise his public image and increase sales, so he either donated millions of dollars to charity or spent the same amount on advertising. One of those scenarios was a purely hypothetical one, the other was real: the Gap’s RED campaign in which the company donated 50% of its profits on certain items to HIV/AIDS and malaria charities.

(MORE: Why There Are No Atheists at the Grand Canyon)

In both cases, a charitable scenario was seen as less moral than an advertising scenario. However, a third group of subjects in both experiments were offered what the researchers called a counterfactual. Those who read the charitable scenario were reminded that the business owner did have the advertising option and chose to promote himself through charities instead. When they were reminded of that half-a-loaf truth—that some charitable giving is better than none—the morality score jumped.

Why we should give a hoot about a donor’s motives at all is something of a mystery. The researchers speculate that untainted altruism may be more predictive of future altruism, and we like to know that a donor who gave today will give again. It could also be that we prefer our cultural prototypes pure. Would Gandhi’s work have been any less great if toward the end of his life he had written a blockbuster autobiography and become fabulously rich? No, but we would surely see him differently.

All the same, do-gooding is still do-gooding. There has never been a sick or homeless person who would have turned down needed medicine or a hot meal because the donor made an honest buck in the process. The help, however it came, is all that mattered.

(INTERACTIVE: Can TIME Predict Your Politics?)

Write to Jeffrey Kluger at jeffrey.kluger@time.com.