The case of the ugly tweet took one more curious turn Saturday and somehow managed to land in the right square, despite numerous missteps along the way.

In a perfect world, School of the Arts senior Ashley Patrick wouldn’t have tweeted an ugly sentiment with racial overtones.

But given that she did, school district officials should have recognized the limits of their authority. They didn’t.

So a student’s off-campus tweet, not sent on school equipment or during school-related activity, got her a five-day suspension, then an expulsion, which was challenged and changed back to suspension.

Then she was told she couldn’t attend the school prom or participate in the School of the Arts graduation.

Just when it appeared the district’s stunning overreach was something Miss Patrick would simply have to live with, things changed again. She was allowed to attend Saturday’s prom, and she was told she may participate in her graduation ceremony.

Ironically, Miss Patrick ended up being suspended just the way the North Charleston Constituent School District Board, which has the authority to decide in such a case, had intended — without being banned from the prom or graduation.

So how did that last reversal occur Saturday afternoon?

Yet another unorthodox move. Charleston County School Board vice chairman Craig Ascue made the call.

He talked with some board members and determined that the board hadn’t really intended for Miss Patrick to miss the prom and graduation.

Some board critics have reasonably said that Miss Patrick shouldn’t have been punished by district officials at all because her offense didn’t occur at school and didn’t interrupt class.

The junior whom Miss Patrick tweeted about might see it differently. She told the school board that she feels victimized, hates going to school and has considered “giving up” since the incident.

Nevertheless, the district failed to offer a convincing argument that the tweet deserved the broader punishment.

Maybe Miss Patrick’s five-day suspension proved instructive.

And it couldn’t hurt for her to write a 500-word essay on race and social media, or to do 20 hours of community service — all part of her ultimate punishment.

Even had school officials recognized they had limited authority to punish Miss Patrick for the tweet, they still had options. They could have called for counseling, parent-teacher meetings and that which schools are supposed to do best — education. Miss Patrick clearly needed to be educated about the hazards of cyber-misconduct.

Perhaps the whole tweet saga will serve to instruct Miss Patrick and her contemporaries.

And perhaps the school district will also learn something about common sense and acting within the limits of its authority.