I don't even recall who posted this, but apparently at Worldcon, Seanan McGuire presented this simple flowchart to explain what is and is not fanfic:

I have no grievance with McGuire in general, but this is both elegant and quite wrong, IMO. Sorry, my Austen fanfic is very much fanfic (and there's no need to give the P&P "variations" industry any more delusions of grandeur than it already has, lol—those are very much fanfic, too). Some of my fics could also be considered re-imaginings or retellings—First Impressions is the obvious example as a deliberate retelling of P&P with genderswapped leads, rather than a true what-if AU—but they are absolutely fanfic. They're fiction written as a form of fan expression.
Sometimes there is a real sense of difference between fiction of this kind, especially when written in a fandom context that is clearly informed by or in dialogue with other fanworks, wider trends in the fandom or in online fandom in general, etc vs some literary re-imaginings that interrogate the source material but are not really fannish (not even in a fan hatred way). So it's not that I think all fiction of this kind should be defined as fanfic. I think that has to do with the conditions of creation rather than the novelty of the cast, setting, and/or plot. But the defining artistic criteria of fanfic as a form or genre are not determined by externally imposed legal codes or the opinion of the source material's author.
There have been many attempts to develop an authoritative definition for fanfic that ultimately comes down to "can you legally make money off it?" But that is not what fanfic is, and I'm deeply skeptical of conceptualizing genre, any genre, based on whether or when it can be sold. A lot of licensed IP writers seem very invested in distinguishing their work from fanfic—sometimes claiming it's not about superiority (sure, Jan), but it's just very important to them that they not be perceived as fanfic writers. But I'd argue that what makes licensed work fanfic or not isn't actually the license, or it being a professional job for money, but the approach of the work in question. Some IP writers are very much fans and clearly approached the licensed work as a chance to write fanfic about some part of canon they're super into with authorization from a parent company or something (various Star Trek writers seem to be very much of this type, say). Others don't really seem to be approaching their work as a form of fan expression, which is not morally wrong in any way, but definitely different. Going back to P&P, there are some takes that I wouldn't really consider fanfic (unlike the variation industry), just because the authors don't seem to be writing as fans but for some other goal. So you sometimes get P&P sequels that are really different from the fanfic—more literary in some ways, but often less engaged with Pride and Prejudice or its adaptations than the fanfic tends to be and prone to little canon errors that fans don't usually make. It's a little hard to describe but you can usually tell.
In any case: some licensed IP work is fanfic and acknowledged as such by the authors, while some isn't; some fanfic is based on source material that is long out of copyright (and some other things based on the same or similar sources isn't fanfic), and the time since publication does not merit a specific respectable distinction from, idk, normie fanfic by Marvel slash superfans or whoever is the fannish target du jour.

I have no grievance with McGuire in general, but this is both elegant and quite wrong, IMO. Sorry, my Austen fanfic is very much fanfic (and there's no need to give the P&P "variations" industry any more delusions of grandeur than it already has, lol—those are very much fanfic, too). Some of my fics could also be considered re-imaginings or retellings—First Impressions is the obvious example as a deliberate retelling of P&P with genderswapped leads, rather than a true what-if AU—but they are absolutely fanfic. They're fiction written as a form of fan expression.
Sometimes there is a real sense of difference between fiction of this kind, especially when written in a fandom context that is clearly informed by or in dialogue with other fanworks, wider trends in the fandom or in online fandom in general, etc vs some literary re-imaginings that interrogate the source material but are not really fannish (not even in a fan hatred way). So it's not that I think all fiction of this kind should be defined as fanfic. I think that has to do with the conditions of creation rather than the novelty of the cast, setting, and/or plot. But the defining artistic criteria of fanfic as a form or genre are not determined by externally imposed legal codes or the opinion of the source material's author.
There have been many attempts to develop an authoritative definition for fanfic that ultimately comes down to "can you legally make money off it?" But that is not what fanfic is, and I'm deeply skeptical of conceptualizing genre, any genre, based on whether or when it can be sold. A lot of licensed IP writers seem very invested in distinguishing their work from fanfic—sometimes claiming it's not about superiority (sure, Jan), but it's just very important to them that they not be perceived as fanfic writers. But I'd argue that what makes licensed work fanfic or not isn't actually the license, or it being a professional job for money, but the approach of the work in question. Some IP writers are very much fans and clearly approached the licensed work as a chance to write fanfic about some part of canon they're super into with authorization from a parent company or something (various Star Trek writers seem to be very much of this type, say). Others don't really seem to be approaching their work as a form of fan expression, which is not morally wrong in any way, but definitely different. Going back to P&P, there are some takes that I wouldn't really consider fanfic (unlike the variation industry), just because the authors don't seem to be writing as fans but for some other goal. So you sometimes get P&P sequels that are really different from the fanfic—more literary in some ways, but often less engaged with Pride and Prejudice or its adaptations than the fanfic tends to be and prone to little canon errors that fans don't usually make. It's a little hard to describe but you can usually tell.
In any case: some licensed IP work is fanfic and acknowledged as such by the authors, while some isn't; some fanfic is based on source material that is long out of copyright (and some other things based on the same or similar sources isn't fanfic), and the time since publication does not merit a specific respectable distinction from, idk, normie fanfic by Marvel slash superfans or whoever is the fannish target du jour.