McKinsey & Company, a consulting firm whose conduct in bankruptcy cases has already drawn the attention of two judges, was accused before a third on Tuesday of improperly receiving and concealing payments from a client on the verge of bankruptcy. This raised the prospect that the judge overseeing the case could order the return of tens of millions of dollars in fees earned by the consulting company.

Signs that something could be wrong at the client company, SunEdison, began to surface after its board hired an outside firm to investigate unrelated employee claims that managers were misstating cash flows. The outside company, FTI Consulting, described an email exchange between a McKinsey consultant and a SunEdison executive, discussing how McKinsey was going to be paid for the work it had already done for the company.

Ultimately, there was an agreement that McKinsey would not keep billing SunEdison itself — instead, it would call back its unpaid bills and redirect them to four solar-energy projects that SunEdison had set up for various customers. But there was a problem: McKinsey had not done any work for them.

“Acknowledge that this is not ideal,” the McKinsey partner wrote, adding that there had not been many options. “We should anticipate spirited opposition from some PMs that we will need to push through,” he added, in a reference to the project managers who would be asked to pay for consulting services they had not received.