James Comey, former FBI director, said Sunday he would agree to a private deposition with House Republicans.

What was the timing?

Comey's statement came after he filed a legal challenged that would force a public hearing.

"Grateful for a fair hearing from judge. Hard to protect my rights without being in contempt, which I don't believe in," Comey wrote in a Twitter post. "So will sit in the dark, but Republicans agree I'm free to talk when done and transcript released in 24 hours. This is the closest I can get to public testimony."

House Judiciary Committee Chairman Bob Goodlatte, a Virginia Republican, issued a statement Sunday that confirmed the plan.

"Mr. Comey will join us for a closed-door transcribed interview later this week," the statement said. "We will release the transcript of his interview to the public as soon as possible after the interview, in the name of our combined desire for transparency."

The release of the transcript was the key to cooperation. Comey had been attempting to make the hearing a public one, but agreed to testify in a private setting provided the transcript be released afterward.

Comey also "moved on Sunday to withdraw his motion to quash the congressional subpoena,” CNN reported.

Comey is set to receive a transcript of his testimony and will have the option of making public part or all of it. He will have the same option with any questions asked during the meeting interview.

An FBI representative will also be on hand to offer advice about the disclosure of FBI information.

Under the agreement, Comey will withdraw his legal motion and the committee will withdraw its subpoena, according to the report..

The announcement followed a court appearance Friday by both sides.

House republicans are investigating how the FBI and the Department of Justice handled investigations into Hillary Clinton's email practices, as well the investigations into Russian interference in the 2016 election. In addition to Comey, the committee is also seeking testimony from former Attorney General Loretta Lynch.