The Harry Potter film franchise, while following the main events of the book series it is based on, does not always leave minor details as they are — and perhaps this was a good decision. For example, watching Harry Potter and the Order of the Phoenix is already a struggle for fans due to the presence of the authoritarian Hogwarts headmistress Dolores Umbridge, but in reality, the scene with Harry's punishment could have had a much more tragic subtext.
In the book, Harry did not tell anyone about Umbridge's bullying — not even Ron and Hermione.
In the film version of Harry Potter and the Order of the Phoenix, Harry's secret about having to go to Umbridge's office for 'detention' after regular classes stops being a secret almost immediately — Hermione notices the cuts on Harry's hands and forces him to tell her the whole truth. In the book, however, the situation is a bit different — Harry never confesses to his friends that the detentions cause him physical pain, and when Ron and Hermione ask what Harry has to do as punishment, he replies that he simply writes the same phrase over and over again. Notably, in this case, Ron and Hermione see nothing wrong with it and even acknowledge that Harry has gotten off relatively easy.
The change in this detail in the film led to the creation of a very accurate storyline that demonstrates violence. In the book, Harry himself did not understand why he ultimately did not tell Ron and Hermione about what was happening — it's quite clear that it was fear and his own shock at what was happening to him that kept him from exposing Umbridge even to his close friends. The cruel headmistress knew very well that everything that happened in her office would stay there, and Harry preferred to try to forget everything and distance himself from the situation — this made Ron and Hermione's comments about the punishment not being that severe even more cruel.