AUSTIN — A federal appeals court has upheld a lower court's ruling that Texas must hire more of two types of protective-services employees who check on foster kids who are lingering in the state's custody after being removed from their birth families.

But U.S. District Judge Janis Graham Jack of Corpus Christi went too far in prescribing how quickly the state must build up a better quantity and geographic dispersal of foster homes and treatment beds for kids in long-term foster care, the appellate judges ruled Thursday.

In a decision that could take months to sort out, a three-judge panel of the 5th U.S. Circuit Court of Appeals said the Texas Department of Family and Protective Services needs more and better-trained conservatorship caseworkers to visit foster children and make sure they are safe.

It also said Texas needs more residential child-care licensing inspectors and investigators.

Outcries by foster children that they are being harmed are not investigated quickly or thoroughly, said a unanimous opinion by Judges Jerry E. Smith of Houston, Edith Brown Clement of Louisiana and Patrick Higginbotham of Austin, formerly of Dallas.

"In short, [the department] is aware of the systemic deficiencies plaguing its monitoring and oversight practices," they wrote.

"It also knows that these deficiencies pose a significant safety risk for foster children. Despite this knowledge, [the department] has not taken reasonable steps to cure the problems. Indeed, it is not clear that it has taken any steps at all."

A lead lawyer for child advocacy groups who brought the class-action suit called the ruling, by appointees of three Republican presidents, "a huge victory for children."

Paul Yetter of Houston, the lead lawyer for the plaintiffs, said youth advocates were sorry to see the appellate judges reverse Jack's orders for a better placement array and a ban on foster group homes.

Still, he noted: "The court found a constitutional violation in the state's failure to provide enough caseworkers. The court also found that the state must enforce licensing standards. Child welfare is about child safety, yet this system isn't getting it done."

More funding could be needed

In December 2016, Gov. Greg Abbott and lawmakers, responding to reports by The Dallas Morning News about Child Protective Services' failure to see endangered children within legally required deadlines, approved funding to hire more than 800 new caseworkers, supervisors and support staff members.

Last year, lawmakers added more money to increase reimbursements to private entities that provide most of Texas' foster-care services.

"The court's decision affirmed many of the changes the state has made in our foster care system," Kayleigh Lovvorn, a spokeswoman for Attorney General Ken Paxton, said in a prepared statement. "While the program still faces challenges, the 5th Circuit upheld significant parts of the program as constitutional and stated that the injunction was overbroad and impractical."

The ruling, however, could force additional spending. It said more workers are needed to protect foster children, though it rejected Jack's "caseload caps" in favor of per-employee workload standards still to be established.

The department "absolutely should determine how many cases, on average, caseworkers are able to safely carry," the majority wrote. "Based on its determination, [the department] should establish generally applicable, internal caseload standards."

Yetter said that will require the state to make more hires.

The decision will force the state "to finally invest what's needed to properly serve these most vulnerable children," he said.

Dallas-based TexProtects-Champions for Safe Children, a group that advocates for abused children, said in a written statement that it was pleased to see the appeals court uphold many of Jack's remedies.

But the group said it regretted that the 5th Circuit "narrowed the district court's prescriptions for change to what it believes is the bare minimum necessary to avoid violating the plaintiffs' constitutional rights."

Among the valuable requirements jettisoned were remedies about "caseload management and establishment of a 24-hour hotline for foster children to report abuse," the group said. It called on lawmakers to do more than just the minimum required by courts.

A seven-year legal battle

The suit was filed in 2011 by Children's Rights, a New York-based advocacy group, and A Better Childhood, a spinoff group started by Marcia Robinson Lowry, founder of Children's Rights. Law firms in Houston and Dallas provided pro bono help.

Texas, under then-Attorney General Abbott and current Attorney General Paxton, fought for dismissal of the class-action suit. Texas has resisted Lowry's suit more ferociously than have any of the 20 states and counties her group sued earlier, she has said.

Jack, an appointee of former President Bill Clinton, held a two-week trial in the case in December 2014. With help from two court-appointed special masters, she ruled that the department must rapidly improve placements, treatment and support for about 10,700 kids who are in the state's "permanent managing conservatorship."

In a separate opinion, Higginbotham said he would have affirmed all three major portions of Jack's remedy order — on building up more foster care beds, not just improving CPS worker caseloads and workloads of licensing inspectors and investigators.

Last year, the Legislature shifted most of the regulatory and oversight personnel from the payroll of the department to the Health and Human Services Commission.

Smith and Clement joined Higginbotham in rejecting Paxton's arguments that federal reviews show Texas is greatly improving foster care and that there's no precise way to measure harm to children caused before and after CPS removes them from birth families.

But Smith and Clement did buy Texas' insistence that states that are custodians for maltreated youngsters don't have to "guarantee the individual's betterment or unconditional stability."

The majority wrote that "foster children are at minimum entitled to protection from physical abuse and violations of bodily integrity." But it said the Constitution's 14th Amendment doesn't "entitle plaintiffs to optimal treatment and services."

The appellate judges on that basis struck down Jack's demands that the state offer a better array of placements and make sure that each child in permanent custody has an attorney ad litem assigned to him or her and receives preparation for "aging out."

In particular, the majority rejected her requirements that the department provide driver's education classes and make sure older teenagers have a birth certificate, Social Security card and email address before they turn 18.