Judge Fernando Mendonça conducts a custody hearing in January 2015.

© 2015 Human Rights Watch

In a sparsely lit conference room, a judge asks a 40ish woman in a leather jacket why she was detained. She was arrested because of a “stupid joke,” she says: posting a photo of herself covered with 100-real notes belonging to her husband. (It was drug money.)

“Did the police mistreat you?” the judge asks.

“Not physically, but they pressured me to confess something I had not done.”

The judge turns over to a grey-haired prosecutor. “The Prosecutor’s Office asks for release, Your Honor.”

“You chose the wrong partner,” the judge tells her in a fatherly manner. She sighs. “But that’s not a crime,” he adds and orders her released pending trial.

That scene – from the September 13 episode of “The Force of Loving,” the most popular soap opera in Brazil – may sound prosaic, but it portrays a long-overdue achievement of the country´s justice system.

Before 2014, no detainee was brought before a judge promptly after arrest. Instead, judges decided whether to order pretrial detention based on the police report. I have interviewed detainees who waited two years in jail to see a judge. That’s not only a violation of a basic right, but terrible policy, as it overcrowds jails with nonviolent suspects who shouldn’t await trial in prison. They are often held in the same cells as convicted criminals.

Since 2014, Brazilian states, with support from the National Council of Justice, have started holding so-called custody hearings, like the one portrayed in the soap opera. That fictional suspect, like many real ones now in Brazil, was judged unlikely to flee or tamper with evidence; she will remain free until her day in court.

But most people detained outside of Brazil´s main cities or on weekends in some capitals still don’t get custody hearings.

Some judges don’t ask about mistreatment by police, according to studies by local groups, and unlike in the soap opera, police officers remain in the courtroom and hear any allegations of abuse – intimidating for a detainee.

Some real-life prosecutors and judges appear to seek incarceration of as many people as possible, instead of considering pretrial detention an exceptional measure, as international law mandates.

Brazil needs custody hearings like the one millions of viewers saw on television, but we still have a long way to go.