With the important reminder that, I’m not a copyright attorney, or any kind of lawyer, for that matter. I’m not saying this as some kind of waver, it’s important to remember, when it comes to the law, my opinions are basically one step above amateur. I took some pre-law classes in college, but opted out of “high school with alcohol poisoning.”
As with all copyright law, this kind of a thing is incredibly contextual, and I’m going to err on the side of caution with this.
If it’s just that you have a character who’s writing a fan fiction of something, then it should be fine.
If you’re intending to also write large excerpts of the fan fiction, include them in the story, and you’re writing professionally, then it’s a little dicier.
The status quo for fan fiction has been, it’s okay to write it, but you can’t sell it. This is entirely based on the whims of the rights holders, and a few are really touchy about fan fiction.
If you’re writing professionally, and this is a story you want to sell, my advice would be to create your own material for them to write a fanfic of. This means you need to do three things. Write the frame story, write the subject matter for the fanfic, and write the fanfic itself. Ironically, this isn’t legal advice, it’s strictly from a writing perspective.
When you’re writing a framed narrative, your themes and concepts need to move fluidly between the frame and the story inside. When you’re writing a fanfic based on a real property, you’re already partially confined by the themes intrinsic to that material. When you’re writing all three, you have full control over the thematic content.
While it might seem easier to write a fanfic for a show you love, it will actually be easier on you to create all three stories from scratch on the spot.