An ad hominem fallacy attacks the person making an argument rather than the argument itself. 'You're only saying that because you're rich,' 'she has no credentials,' 'look at his history' — none of these engage the claim. A dishonest person can state a true fact; a hypocrite can make a valid argument. The argument's merit is independent of who's holding it.
The subtlety worth learning is when it isn't a fallacy. If someone is offering testimony rather than an argument — 'trust me, the data says so' — then their credibility, expertise, and conflicts of interest are directly relevant, because you're being asked to rely on them personally. The distinction: attacking the source is legitimate when the source is the evidence, and fallacious when actual reasoning has been presented that you could evaluate on its own. The related trap is tu quoque ('you do it too') — a hypocrite's inconsistency says nothing about whether their claim is correct.
Naomi Oreskes and Erik Conway's Merchants of Doubt documents how the tobacco industry, facing mounting evidence linking smoking to cancer, ran a strategy that rarely tried to refute the science directly. Instead, industry-funded groups attacked the scientists — questioning their motives, funding, and competence — and amplified a small number of contrarian scientists whose credibility was invoked against the mass of evidence. An internal Brown & Williamson memo from 1969 stated the strategy with unusual candor: 'Doubt is our product, since it is the best means of competing with the “body of fact” that exists in the minds of the general public.' The same playbook, and in several documented cases the same individuals and organizations, later moved to acid rain, the ozone hole, and climate change. The tactic works because attacking a person is concrete and memorable, while the underlying evidence is abstract and boring.