The only way around this problem in the future is to make IRS agents personally responsible for such abuses, no matter who ordered them to obey.
Lots of SS soldiers ended up dangling from a rope, even though they were only following orders. So IRS employees need to be given a deal: If you refuse to improperly audit someone, you might be fired; but if you obey, you might end up in federal prison. If not immediately, then after that corrupt supervisor is long gone.
Something along those lines is needed. Until the politics is taken out of the IRS this type abuse will continue.
From my years in Government I have come to the conclusion that all government employees from the lowest to the highest and no matter what service is involved especially law enforcement and political clerks must be held to the same societal standards as the ordinary citizen is. I know there are cases that are given public review, but these are for show as much as for social justice. Many public employees hide behind the so called ‘public service immunity’ but this has to be eliminated so that any such public employee knows from the git-go that honest and open service is a way of life.