For weeks after President Trump’s inauguration in 2017, Richard Cordray waited to be fired.

The then-director of the Consumer Financial Protection Bureau had long been a target of Republicans frustrated by the power wielded by the new agency — a brainchild of Sen. Elizabeth Warren (D-Mass.) — including the limits on the president’s ability to fire him.

The possibility that Trump would test those constraints and immediately move to fire Cordray “loomed over everything,” according to Cordray’s book “Watchdog,” which will be published Monday.

Cordray says he hired an attorney and prepared for a fight to keep his job. But instead of a dismissal notice, he received an invitation from Gary Cohn, who was head of the National Economic Council and a former Goldman Sachs executive, to meet for dinner at Trump’s new D.C. hotel. Cohn had been tasked with deciding his fate but didn’t want a big fight, Cohn told him. They settled on a temporary truce that left Cordray in place for nearly a year.

The U.S. Supreme Court is scheduled to hear arguments Tuesday in a case that could determine once and for all whether a president can fire the CFPB director “at will.” The ruling could shape the future of the 1,600-person bureau and throw into question the legitimacy of the billions of dollars in fines it has imposed on mortgage lenders, credit card companies and banks over the past eight years.

The court will be hearing the case of a California law firm, Seila Law, which has refused to cooperate with a CFPB investigation, arguing that the bureau’s leadership structure is unconstitutional.

“It is an important test of what level of independence executive agencies can have in the latest version of the Roberts court,” Christopher L. Peterson, a former senior CFPB official and a professor at the University of Utah’s Law School, said of Chief Justice John G. Roberts Jr.

A 2007 paper by Warren, written when she was a Harvard law professor, was the guiding force behind what became the CFPB in the wake of a global financial crisis. But the bureau was controversial from the start, with Republicans calling for changes to its structure, including having it funded through Congress rather than the Federal Reserve, giving lawmakers more oversight power.

Warren, President Barack Obama’s top pick to be the bureau’s first director, rejected the idea of legislative compromise, according to “Watchdog.” She said “her first choice was a strong consumer agency, her second choice was ‘no agency at all and plenty of blood and teeth left on the floor.’”

Cordray’s book is largely a love letter to an agency he helped establish (he was one of the first 12 employees), but it also gives insight into some of its controversial moments.

Wells Fargo, the embattled San Francisco bank, initially tried to “stonewall” an investigation by the Los Angeles city attorney of whether its employees were improperly opening accounts customers didn’t want, according to “Watchdog.” Wells Fargo tried to “tie [the city] up in protracted discovery, which is a classic defense strategy in difficult cases.”

The bank’s resistance crumbled as the CFPB, which has broader powers, intervened, and Wells Fargo agreed to settle, Cordray says. But the bank wanted to keep key details from public view, including that more than 5,000 employees had been fired for opening millions of accounts customers didn’t want. “The bank fought hard to control the spin and minimize the issue, suggesting that the number of problem accounts was only about 1% of its total accounts,” Cordray writes.

The bank didn’t immediately respond to a request for comment.

He also has few kind words for his successor, Mick Mulvaney, whom Trump appointed acting director when Cordray stepped down in November 2017 and began a failed bid to be the governor of Ohio. Mulvaney, who as a South Carolina lawmaker called the CFPB a “joke” and co-sponsored legislation to get rid of it, levied fewer and smaller fines, dropped lawsuits against payday lenders, and softened proposed regulations for debt collectors while acting director.

Mulvaney’s leadership was a series of “public relations stunts,” Cordray writes, and some of his views were “bizarre and almost cartoonish.”

The bureau’s future is now in the hands of the U.S. Supreme Court.

In 2017, the CFPB was investigating whether Seila Law engaged in “unlawful acts or practices in the advertising, marketing, or sale of debt relief services,” including whether it illegally charged consumers upfront for debt-relief help. The bureau sent the firm a civil investigative demand, essentially a subpoena, asking for documents as part of its investigation, according to court documents.

But Seila largely refused to comply, arguing that the bureau’s unconstitutional structure rendered the order illegal. If the CFPB director can be removed only “for cause,” that intrudes on the president’s ability to direct and control the executive branch and violates the separation of powers, the firm argued.

The CFPB is “an agency like no other,” according to a motion filed by Seila. “Headed by a single director who does not answer to the President, the CFPB exercises vast executive power against private parties.”

The bureau’s defenders say its independent structure shields it from inappropriate political pressure, which is particularly important given the power the financial industry can wield in Washington.

Complicating the case, Kathleen Kraninger, the CFPB’s current director, has declined to defend its structure, essentially siding with Seila. The Supreme Court appointed Paul Clement, a former U.S. solicitor general, to defend the bureau in court.

Among justices deciding the bureau’s fate is Brett M. Kavanaugh, who while on the U.S. Court of Appeals for the D.C. Circuit said in a different case that the bureau’s structure was unconstitutional. Independent agencies such as the CFPB constitute “a headless fourth branch of the U.S. Government. They hold enormous power over the economic and social life of the United States,” he wrote in a 73-page dissent.

Kavanaugh is not obligated to recuse himself in the Seila case.

If the court rules that the CFPB’s structure is unconstitutional, it could simply strike the language in the law that limits the president’s ability to fire the director or order Congress to make broader changes, legal experts following the case say. But some financial companies may use such a decision to challenge the legitimacy of former or existing CFPB investigations, said Joann Needleman, a Pennsylvania-based lawyer who represents companies with CFPB cases.

“If they laid out $30, $40 million [in fines], the companies are going to argue that the orders were made under false pretenses,” she said.

In the unlikely case that the court strikes down the entire section of the law creating the CFPB, it would create havoc, legal experts say.

“If the CFPB ceases to be a going concern, what happens to all of its regulations?” asked Peterson, the former CFPB official. “It would create a big crisis that Congress would have to solve, and it’s the kind of thing that Congress is not likely to do a good job of right now.”

Robert Barnes contributed to this report.

Read More: