In a Santa Ana courtroom Friday morning, Scott Evans Dekraai will learn whether he could face execution for the worst mass killing in Orange County history.

After six years of delay and a series of controversies that rocked the county’s criminal justice system, Superior Court Judge Thomas Goethals has two options. He can open the way for a jury to decide 47-year-old Dekraai’s fate.

Or Goethals could become one of the rare judges to take execution off the table for a convicted murderer because of law enforcement misconduct. In that case, Goethals would likely sentence Dekraai to eight consecutive life terms without parole.

“It’s a notable case because it’s a serious crime and there is unparalleled prosecutorial misconduct,” said Robert Dunham, executive director of the Death Penalty Information Center, a non- profit organization that tracks capital cases nationwide.

Goethals’ decision will hinge on his judgment of the Orange County Sheriff’s Department and whether it can be trusted to hand over evidence that could benefit Dekraai’s defense. Goethals’ decision also will be based on whether he believes the department withheld and destroyed documents showing jailhouse informants were used improperly. Goethals had issued a 2013 court order to turn over the documents.

Dekraai’s attorney, Assistant Public Defender Scott Sanders, recently argued before Goethals that “the sheriff’s department has attempted to create a false and misleading narrative about this case…They are content to let this defendant be misled.”

But state Deputy Attorney General Michael Murphy, the current prosecutor, reminded Goethals that his job isn’t to punish law enforcement for any misdeeds.

“(This is) not a forum for the defense to investigate the sheriff’s department…nor is it a government oversight hearing,” Murphy said. “It’s about the prosecution of (Dekraai) for murders he’s admitted.”

For more than four years, the October 2011 shooting rampage that killed eight people at a Seal Beach beauty salon has taken a back seat to the legal jousting over the use of jailhouse informants to improperly secure confessions from targeted inmates.

Ironically, Dekraai’s guilt was never really in doubt. Within minutes of the shooting, he confessed to Seal Beach police, and then pleaded guilty in 2014. Dekraai appeared to be on the fast track to join the 748 prisoners on California’s Death Row, and about 2,900 nationwide.

But his case got derailed when Orange County prosecutors and sheriff’s deputies made what they contended was an honest mistake days after the shooting. They bugged Dekraai’s jail cell and sent a prolific informant to get him talking. That was a violation of Dekraai’s constitutional rights, because he had a lawyer and had been formally charged, Sanders said.

Prosecutors maintained it wasn’t a violation because they instructed the informant to listen and not to ask any questions about the case. The gambit came back to haunt them.

Sanders had the reputation in the district attorney’s office as a courtroom Chicken Little, constantly accusing prosecutors of misconduct. But the accusations not only stuck this time, but generated more evidence.

Sanders learned of the informant and realized the same inmate had been used with another of his clients, Daniel Wozniak, who killed two people to fund his wedding. Sanders figured it was not a coincidence, but a sign that police and prosecutors had forged a surreptitious network of jailhouse informants, and he set out to press his concerns with Goethals.

From that point on, Dekraai’s punishment was delayed as the so-called “snitch scandal” unfolded. With legal scholars and the media watching nationwide, Sanders uncovered evidence that prosecutors and deputies had cheated for up to 30 years, misusing jail informants and not telling the defense.

For instance, Sanders recently obtained a Dec. 27, 2009 sheriff’s department email detailing how the jail’s color-coded security wristbands were changed for informants, to make them more credible to targeted inmates. Eight deputies participated in the scheme against an inmate accused of attempted murder — a scheme requested by a Santa Ana Police investigator, according to the email.

District Attorney Tony Rackauckas has fought back, saying any misconduct was unintentional and that the controversy was overblown. Sheriff Sandra Hutchens has said there was no sanctioned informant network operating in her five jails, putting the blame on some rogue deputies.

And the 2016-17 Orange County Grand Jury called the scandal a “myth,” spread by an uninformed media.

But the state’s 4th District Court of Appeal, in November 2016, found cheating by Orange County prosecutors and sheriff’s employees was real and systemic. Appellate justices upheld a 2015 decision by Goethals to take the case away from the district attorney’s office because he did not trust local prosecutors to ensure Dekraai a fair penalty trial.

The U.S. Department of Justice is investigating both the district attorney’s office and the sheriff’s department’s handling of informants. Meanwhile, at least six murder and attempted murder cases have unraveled in Orange County because of informant issues raised by Sanders.

One of those cases involved Isaac John Palacios, who pleaded guilty in 2014 to killing a rival gang member. He was released from jail within hours of that plea, serving only 3 ½ years on what could have been a life sentence.

The reason for the plea deal: prosecutors said they did not want to open the case up to the same scrutiny as Dekraai because of informant concerns.

Since 2013, 60 witnesses have testified in three special hearings before Goethals, with the case growing worse for local law enforcement.

During the current proceedings, a half dozen deputies refused to testify, invoking their 5th amendment rights against self-incrimination. Three of the deputies are being investigated by the state Attorney General’s Office for suspected perjury during prior hearings.

Goethals has voiced anger and frustration over what he calls the sheriff’s department’s apparent inability or unwillingness to produce documents ordered by the court.

The drip, drip of the release of documents has kept the focus on the role of the sheriff’s department and away from Dekraai’s crime and the suffering of the victims’ families.

After assuring the judge that no documents existed, the sheriff’s department in late 2014 turned over TRED records, which document the movement of inmates inside the jail. Deputies admitted trying to keep those records confidential during a previous hearing .

Then Sanders learned of computerized “special handling logs,” notes kept by deputies about their interactions with informants. After more prodding by Sanders and the judge, the department eventually found 1,157 pages of those notes, which officials said were unauthorized and unread by sheriff’s department brass.

And thousands of pages of additional notes and 68 boxes of documents that had not been looked at were uncovered. Finally, prosecutor Murphy’s team found 30,000 emails and notes in sheriff’s department computers, but decided not to give them to Sanders.

“They (sheriff’s employees) are not giving answers that make sense and neither is the attorney general,” Goethals said during the current hearing.

On Friday, the legal maneuvering finally returns to Dekraai and the lives he took: Victoria Buzzo, 54; David Caouette, 64; Randy Lee Fannin, 62; Michele Daschbach Fast, 47; Michelle Marie Fournier, 48; Lucia Bernice Kondas, 65; Laura Webb Elody, 46; and Christy Lynn Wilson, 47. Hattie Stretz was also shot, but survived.

Goethals has said he will take into account the families’ feelings. Some are encouraging him to block the death penalty, so they will not have to attend more court proceedings.

Other relatives of the victims want Dekraai to die.

What’s clear is that Orange County’s justice system has been altered in many ways.

Rackauckas has added a new training workshop at the sheriff’s academy on using informants and the rights of inmates; as well as preserving defense evidence.

Defense attorneys are scouring their cases for informants, demanding more information on their histories and how they were used. Attempts are being made to reopen cases based on the improper use of informants.

And there is heightened sensitivity about the potential for prosecutors and law enforcement to improperly seek an edge in criminal cases.

“When the prosecution engages in misconduct designed to give a tactical advantage, the judge will remove the advantage,” said Dunham, of the Death Penalty Information Center.