I'm not surprised the courts would uphold district policies to secure the school. The question that still hasn't been answered is that if simply wearing an American flag is enough to spark worries of inciting violence, then why hasn't the district banned Cinco de Mayo celebrations in school? It obviously brings instability into the school and associated security risks.
I would not call that a good explanation; I’d call it a bigoted explanation not based in reality, since they said that Mexican students are prone to violence over free exercise of rights in the USA. The First Amendment plainly states that the kids with US flags on have a right to do so.