Court-ordered inpatient rehab places you in that facility's custody. Leaving without permission is a new criminal charge, often a felony.
Escape charges frequently arise when someone is sent to a court-ordered inpatient rehabilitation facility and leaves without permission. While there, you are legally in that facility's custody under a court order, so leaving is an escape charge.
Most people end up in one of those facilities because of a felony drug charge, which means the escape charge is also a felony. People assume it will be handled as a probation or pretrial-condition violation, and instead they are facing a brand new felony case on top of the original one.
Citation: Texas Penal Code §38.06
Degree and classification
Statutory language: A person commits an offense if the person escapes from custody when the person is under arrest for, lawfully detained for, charged with, or convicted of an offense.