I\'m trying to build my first editor add-on where the same codebase is supposed to work on Docs, Sheets and Slides.
I\'m still in the testing phases and that\'s where I\
When a script file is loaded into memory for execution of any function (onOpen or any other function), all global variables are loaded/executed. Your issue stems from attempting to get the active(getActive*()) document under AuthMode.None.
If you can get to Ui without getting to getActive() that's possible. But you're attempting to access the document inbetween:
SpreadsheetApp .getActiveSpreadsheet() ? SpreadsheetApp.getUi().
The bolded part is causing the issue. SpreadsheetApp.getUi() will work fine.
You can also try try{...}...catch(e){} instead.
Authorization modes - Access to document: No under AuthMode: "NONE" table
Related answer - May not work.