TheMDmaster11
Do you mean a Harry Potter fanfic? There's a couple of them in the top 100. There's also tons of DBZ and Naruto fanfics. If you're using the Harry Potter world and/or characters, then you could never make money off the novel since you don't own the copyright. But plenty of people write fanfics for their favorite novels. Obligatory: I'm not a lawyer and you should not take this as legal advice. It's extremely unlikely your fanfic would ever get taken down. If it was to be taken down then it'd likely be because the copyright owner of the Harry Potter books sent a DMCA request for it to be taken down. Considering that there are tons of fanfics of Harry Potter floating out there, I doubt they would ever do so. Especially since it doesn't hurt them financially in any way.
Now if you instead plan to create a world similar to Harry Potter while not using its characters, places, etc. then there's nothing they could do to you and you could publish and profit off the novel if desired. Harry Potter doesn't own any exclusive rights to spells, wizards, trolls, and other fantasy settings.