> This is what I meant by "round trip enabled"
Aha, ok. What you mean is 'return link'. The term roundtripping is used e.g. when you export a document to IDML, fix something there, and import the IDML. Then you say you roundtripped via IDML.
That was the simple bit. Now the other problem.
> I got the "text anchor not found" when exporting.
This is a terrible bug in InDesign. I wouldn't have expected it here. When you once generate a TOC with a script, then when you create the TOC with 'Make text anchor in source paragraph' enabled, they aren't so that you get the error you saw when you export to PDF. But in these documents the TOC was never created with a script (as far as I remember, anyway) so it's not really clear to me what's going on.
But even if you wouldn't have seen the error, these endnotes are a problem when exported to Epub (or PDF). The problem is that the real endnotes arestill in the chapters, on a non-printing layer. So there is no relation between the 'endnotes' in the back and the note references in the text.
Adding hyperlinks to navigate back and forth between notes and their references is problematic. In the text, the references are already hyperlinked by InDesign, they point to the notes in the chapter, but because they're on a non-printing layer those links appear dead in the Epub. So you can't add a link. And for some reason you can't create hyperlinks in the notes in the back of the book, maybe because you can't do that in general in TOC entries (which those notes really are). Export to PDF is much better, not only because you can do notes as pop-ups.
So on balance, if you want to export to Epub and if you want two-way links between notes and the references, the script on github should be your starting point. With that one it should be possible to add the links.
... View more