Trump is angry at Michael Cohen, of course, because Cohen just pleaded guilty to (among other things) making an illegal contribution to Trump’s 2016 presidential campaign by paying hush money to Stormy Daniels just before the election. Moreover, Cohen told the judge in the case that he did so “in coordination with and at the direction of” Trump.

Cohen’s actions were illegal because individuals may only contribute a limited amount of money or in-kind services to political campaigns. During the 2016 election, the maximum was $5,400. Cohen fraudulently obtained a home equity loan and then wired $130,000 of it to the lawyer representing Daniels on October 27, 2016.

What Trump certainly doesn’t understand, and what makes his tweet extra-wonderful, is that the problem with Cohen isn’t just that he (in Trump’s mind) betrayed Trump. It’s that Cohen is genuinely a terrible lawyer.

J.P. Morgan famously said, “I don’t know as I want a lawyer to tell me what I cannot do. I hire him to tell me how to do what I want to do.” But what Cohen managed to do was fail in both ways. He didn’t tell Trump that Trump couldn’t pay off Daniels using Cohen himself as a conduit — but he also failed to advise Trump that there was a way to do it that would have been totally legal.

Here’s how.

Donald Trump (and only Donald Trump) could legally donate an unlimited amount of money to his campaign, because he was the candidate. Therefore, he would have been in the clear if he had made an in-kind donation to his campaign by paying Daniels directly with his own money. He could also have used money raised by his campaign, including his own contributions, to pay Daniels. (Trump’s campaign took in a total of $333 million, with $66 million of that coming from Trump himself.)

In either case, Trump’s campaign would be required to eventually disclose the expenditure. And under federal law, the campaign would also have had to disclose the contribution within 48 hours of receiving it, assuming Trump’s hypothetical contribution to the campaign were made within 20 days of the election. (If Trump had just paid off Daniels with money already contributed to the campaign, by himself or others, such an immediate disclosure would not have been necessary, but the expenditure might have been reported on the campaign’s so-called “pre-primary” report.) But even then, the disclosures might not by themselves necessarily expose the wrongdoing.