The odd couple of JPMorgan Chase and Twitter made news this week when the bank canceled a planned Q&A session featuring its vice chairman, Jimmy Lee, because it attracted a ton of hostile tweets such as “When [JPM chief] Jamie Dimon eats babies are they served rare?”

The bank and the social media company are linked in another way, as well: they’re both being accused in Washington of dodging taxes. But in both cases, the companies are getting what I consider a bum rap. And I’m someone who has spent years writing about tax loopholes, hoping to get some of them closed.

Let’s start with JPM, which last month wrote $5.15 billion worth of checks to Fannie Mae and Freddie Mac, the two big government-sponsored enterprises, to settle lawsuits they filed against the bank three years ago in a commercial dispute over mortgage dealings. Those payments — settlements of civil lawsuits that have nothing to do with alleged criminality — are classic examples of deductible business expenses.

But there’s uproar and screaming in Washington, where legislation has been introduced to stop JPM from being able to deduct those payments from its taxes. Fines and penalties aren’t deductible, but JPM isn’t being fined or penalized in this case — all it has done is settle a commercial lawsuit.

What the block-that-deduction crowd hasn’t said — and few people realize — is that every penny JPM paid Fannie and Freddie will go to taxpayers. That’s because both firms (quite properly, in my opinion) are required to remit all their profits to the Treasury to compensate taxpayers for bailing them out five years ago.

Yes, taxpayers would be further ahead if the Treasury got the $5.15 billion without JPM being able to save 35 cents on the dollar by deducting it. But is that reasonable? Or fair? I think not.

Now to Twitter, which Sens. Carl Levin (D-Mich.) and John McCain (R-Ariz.) complain is getting a $154 million tax deduction because employees cashed in option profits as part of the company’s initial public offering of stock.

Under current tax law, you see, the profit that an employee makes by cashing in a stock option creates an offsetting deduction for the employer. It makes perfect sense to me, because the option profits are employment income to the employees, so logic suggests that’s a deductible employment expense to the company.

Levin and McCain’s Senate Permanent Subcommittee on Investigations has done God’s work exposing things like Apple’s obnoxious tax games. But in this case, the lawmakers are just making noise. They contend that Twitter and other options-granting companies should be allowed to deduct only the value they placed on the options when they granted them. In Twitter’s case, $7 million.

In the case of Twitter’s options, as in the case of JPM’s Fannie and Freddie payments, taxpayers are coming out way, way ahead.

Let me show you why. Twitter’s option-related deduction is worth 35 cents on the dollar, because the top corporate tax rate is 35 percent. However, the Treasury will collect considerably more from employees than Twitter will save.

Assuming that options-exercisers are top-bracket payers, they will shell out 39.6 percent income tax on their options profits; 1.45 percent of Medicare tax; and 0.9 percent for the Medicare high-earner surcharge. Total: 41.95 percent. In addition, Twitter will match the 1.45 percent of Medicare tax. Add it up, and the 35 percent Twitter deduction is way more than offset by 43.4 percent of income and Medicare taxes. (I’m not taking state and local taxes into account, or the fact that Twitter’s 1.45 percent Medicare tax is deductible.)

The real loophole, as my Fortune colleague Dan Primack has pointed out, isn’t Twitter deducting the profits employees realize from exercising stock options. Rather, it’s the tax that venture capitalists won’t be asked to pay on their share of their investors’ profits in Twitter stock when it’s sold.

Under a fair tax setup, the venture capitalists’ “carried interest,” which I estimate at $1 billion based on Dan’s work, would be taxable as ordinary income, resulting in the same 43.4 percent for the Treasury that Twitter and its employees pay on option profits.

However, because carried interest income is taxed as capital gains, the venture capitalists’ rate is only 23.8 percent: the 20 percent capital gains rate and the 3.8 percent surcharge on high earners’ investment income.

That difference to the Treasury — 19.6 percent on $1 billion, way more than the alleged Twitter loophole — is the real scandal. But so far, despite years of talking about closing this loophole, it remains.

If the politicians picking low-hanging PR fruit by attacking JPM and Twitter close the carried interest loophole, I’ll salute them. But I’m not holding my breath waiting for this to happen.

This column reflects the deletion of a snarky paragraph saying that Levin and McCain oppose letting companies deduct the value of options that expire worthless. In fact, they support letting companies deduct options when granted, regardless of whether they expire worthless. Sorry for the mistake. 

Sloan is Fortune magazine’s senior editor at large.