MWE:
\documentclass{article}
\usepackage{endnotes}
\usepackage{amsthm}
\theoremstyle{definition}
%\newtheorem{note}{Note}
\begin{document}
\endnote{Blabla}
\theendnotes
\end{document}
It's an issue that only appeared once \end... started to be a thing. I'm not sure about a good solution, but possibly testing that \endnote has its original defintion could help; the test could be added to the begin/end document and/or \theendnotes.