Earlier this month, a federal appeals court dealt PNC Bank, Inc., a fatal blow in the company’s effort to obtain insurance coverage for the $102 million it paid to settle overdraft-fee class actions several years ago. The ruling comes at the tail end of a legal roller coaster in which the bank ultimately got no insurance coverage. Worse, but for drafting errors by its lawyers, it could have gotten at least $30 million in coverage.

The decision in PNC Financial Services Group Inc. v. Houston Casualty Company shows what types of things can happen during a class-action claims dispute. For example, the legal rulings went from completely in PNC’s favor to completely against it. A magistrate judge found that PNC was entitled to full coverage; the district court judge then disagreed, finding coverage for only $30 million; and finally the court of appeals said the bank should get nothing.

All of this would seem to give PNC solid grounds to argue that its insurance policies were ambiguous and, under normal rules of contract construction, should be interpreted in its favor. But the United States Court of Appeals for the Third Circuit said “no,” opposing legal opinions do not indicate ambiguity. That court also disagreed with PNC’s other main argument: that the exclusions on which the insurers relied were being applied so expansively that the underlying insurance coverage was illusory.

But by far the most disturbing part of the decision related to the $30 million in attorneys’ fees that PNC paid as part of the overdraft settlements. The attorney fees were structured to come out of the entire pool of class proceeds and not separately from PNC itself. Had the settlement been designed so that PNC was directly responsible for that money, then its insurance policies would have kicked in for those amounts. So the teaching moment is this: if your company is considering settling a class action, make sure your lawyers consider any possible insurance ramifications. PNC’s former attorneys, who failed to do that, likely just walked their firm into $30 million in malpractice liability.