I mean imo JKR is a bad author for about a dozen reasons but that line in particular is not me of them.
Tbh the entire plot hinging on the idea that it is unthinkable to every single person in the Wizarding world that someone would prank the most famous kid in school by putting his name in the cup without his knowledge is a way worse writing decision. Given that’s exactly what happens though Dumbledore acting calmly and implying he knows Harry didn’t actually do it is the most reasonable thing to come out of that book.