— A federal appellate court on Monday upheld a South Carolina school district’s decision to bar a student from wearing shirts with the Confederate battle flag on campus, ruling that school officials need to keep order and promote education.

“Although students’ expression of their views and opinions is an important part of the educational process and receives some First Amendment protection, the right of students to speak in school is limited by the need for school officials to ensure order, protect the rights of other students, and promote the school’s educational mission,” the 4th U.S. Circuit Court of Appeals wrote.

In 2006, the North Carolina-based Southern Legal Resource Center filed a federal lawsuit against the Latta School District on behalf of Candice Hardwick, then a 15-year-old high school sophomore. Hardwick had been forced to change clothes, turn shirts inside-out and was suspended twice for Confederate-themed clothing in middle school. Hardwick’s attorneys argued that a ban on wearing the Confederate emblem violated her right to free speech.

Three years later, a federal judge in South Carolina tossed out that notion, ruling that Hardwick’s attorneys didn’t have enough evidence to succeed with their case. U.S. District Judge Terry Wooten wrote that district officials, fearing possible disruptions if Confederate-themed clothing were allowed in the racially diverse schools, acted reasonably in banning such items.

The appellate court also dispensed with arguments that the school’s dress code was too vague.

Kirk Lyons, an attorney for the Southern Legal Resource Center, did not immediately return a message seeking comment on Monday.

Lyons’ group had argued that a 2002 decision from the 6th U.S. Circuit Court of Appeals involving a Kentucky high school student is central to Hardwick’s situation. In 1997, Madison Central High School student Timothy Castorina sued after he was suspended for wearing a Confederate flag T-shirt. A federal judge tossed out the case, saying T-shirts aren’t a form of free speech. An appeals court overturned that decision, and the school settled.

Hardwick’s family has said the teen’s desire to show Confederate pride by sporting T-shirts, belt buckles and cellphone covers bearing the red flag crisscrossed with blue stripes and white stars is a family thing.

When Hardwick kicked off the last week of school in May 2006 by staging a protest march into the high school, her father said two of his great-great grandfathers had been Confederate veterans — including one who was wounded at Gettysburg.