Earlier quoted context omitted.
It would be trademark infringement to use the names, it would be copyright infringement to use the meaningful content of the plot and story.
Not sure that’s correct. Copyright attaches to the actual text (illustrations, etc; whatever is “fixed in a tangible form”), not the ideas. You could write a story about a boy of humble origins who is whisked off to a special school, discovers he’s special, and fights evil. There aren’t that many original plots, after all.... You’ll only get into trouble if the main character is called Harry Potter of 10 Privett Driv…
[1] https://en.wikipedia.org/wiki/Copyright_protection_for_ficti...