Barring an unexpected change, the Donald J. Trump Foundation will be defending itself in a New York courtroom shortly before this fall’s midterm elections. The proceedings seem unlikely to go well for the institution and its leadership; President Trump and his elder children, Ivanka, Donald, Jr., and Eric, are being sued by New York’s attorney general, Barbara Underwood, for using the charity to enrich and benefit the Trump family. On Tuesday, the judge in the case, Saliann Scarpulla, made a series of comments and rulings from the bench that hinted—well, all but screamed—that she believes the Trump family has done some very bad things.

The judge seemed frustrated, even confused, that the Trumps were fighting the case at all. At one point, she told a lawyer for the Trump children that they should just settle out of court and voluntarily agree to one of the sanctions: a demand by the Attorney General that they not serve on the boards of any nonprofits for one year. (The case will be tried in civil court, and the Trumps aren’t facing any criminal charges.) That’s far from the worst sort of punishment, but to accede to it would be a public embarrassment and an acknowledgement that the family did, indeed, use the foundation as something of a private slush fund to enrich themselves and reward their cronies. Judge Scarpulla made clear that she felt the children should agree to the sanction now, and that, if they don’t, she will probably impose a similar restriction “with or without your agreement.”

The case against the Trumps appears damning. Charitable foundations are governed by a crucial compromise: they can operate without paying taxes on the condition that their leadership insures that all money spent is spent in pursuit of the public good. The case brought by Attorney General Underwood shows that the Trump Foundation was neither well-managed nor focussed on what would generally be considered the public good. Its operations were shockingly sloppy; at least one of the organization’s official board members said that he had no idea he was on the board and that the board had never met, to his knowledge. No surprise, then, that the other controls that normally govern nonprofits were absent. As David Fahrenthold, of the Washington Post, exposed in a series of stories in 2016, the Foundation did virtually none of the charitable things it claimed to be doing.

In recent years, the only “contributions” to the charity seem to have been payments from business partners, not from the Trumps or the Trump Organization. The charity’s spending appears to have benefitted the Trumps themselves, not the public welfare. The organization had been operating this way for years, but, according to Underwood, in 2016 the Trump Foundation became an arm of the Trump political campaign, cutting checks to Trump’s political allies in key states just before the election. If true, this would mean that the Trump Foundation evolved from a mere tax-avoidance scheme into an instrument for carrying out potential acts of campaign-finance fraud. The Attorney General made clear that her evidence could support criminal cases against the Trumps, but she has no jurisdiction to bring such charges, since tax and campaign fraud are federal matters. She referred the case to federal officials, though it seems unlikely that the I.R.S. or the Federal Election Commission would choose to prosecute a sitting President or his children.

During Tuesday’s hearing, the Trump Foundation’s lawyer, Alan Futerfas, asked that the trial not commence in October, because it was so close to the midterms. Judge Scarpulla laughed in response, did not change the trial date, and hinted that she is likely to require the President to testify. It is not clear, however, that such a trial would dramatically change how people vote; it was clear during the 2016 Presidential election, thanks to Fahrenthold’s reporting, that the Trump Foundation was almost certainly engaged in systematic fraud.

The case might not shift voting patterns, but it will provide one of the clearest views yet of the inner workings of the Trump Organization. Most private companies keep their internal financial information secret. The Trump Organization, though, is unusually opaque. Even now, despite all of the scrutiny it has faced, there is much we don’t know about how it raises funds, spends money, and functions internally.

A series of subpoenaed e-mails and a fascinating deposition offer a glimpse into the work of a mysterious figure, Allen Weisselberg, who has handled Donald Trump’s finances for as long as he’s had any. First hired by the President’s father, Fred Trump, Weisselberg has been the one steady presence in the Trump Organization for the entire period that Donald Trump has run the company. I have spoken to many current and former Trump Organization employees who have shared the same description of the company: it is a chaotic mess, in which projects are randomly distributed to in-house staff. A lawyer might be asked to negotiate a real-estate deal, an executive might be tasked with setting up a product-licensing arrangement. While there are traditional titles, such as general counsel or senior vice-president of operations, there is no standard business hierarchy. Trump, before he became President, would tell people what they should do with no clear regard for consistency. The currency of the place was always one’s proximity to the big boss, Donald Trump, so people didn’t tell colleagues which projects they were handling, out of fear that those colleagues might undermine them. I heard, repeatedly, that there were only two people who knew about every deal the company made: Trump himself and Allen Weisselberg. However, Trump, rather famously, rarely concerned himself with details and often forgot who had received which assignments and how different deals were structured.

Weisselberg’s testimony in the trial, then, could prove revealing. He is perhaps the only non-family member who knows the inner workings of the Trump Organization. Michael Cohen will be a key figure in understanding Trump’s recent business relationships with several overseas partners suspected of potentially engaging in money laundering, corruption, and sanctions violations. (A federal criminal investigation of Cohen includes more than four million business files that will soon be turned over to investigators and are likely to shed light on the company’s operations during the ten years that Cohen was involved.) But it is only Weisselberg who can recount the essence of the Trump Organization from the beginning of Donald Trump’s involvement: in the nineteen-seventies, when the company first discriminated against African-Americans; in the eighties, when Trump appears to have been in business with the New York mafia; in the nineties, when Trump’s casino was in violation of anti-money-laundering laws; and through the aughts, as Trump developed ties to many Russian and former-Soviet oligarchs and political figures.

The Trump Foundation case may have already revealed a potential rift between Weisselberg and the family. His deposition in the case is fascinating reading. Weisselberg makes it quite clear just how sloppy an operation the foundation was, with no meetings and no careful accounting. In a compelling exchange, Weisselberg describes how he flew to Iowa with a checkbook to give money to political allies of Trump, then a Presidential candidate, and he makes it clear that he did this because his boss told him to. It is a damning statement, and the first evidence I have seen that Weisselberg, when cornered, may be willing to shift blame to the President. Judge Scarpulla will continue pushing the Trumps to settle. Trump-watchers, though, will likely hope that the family chooses to fight. We will learn much more if Weisselberg and others take the stand.