So my company recently moved from a shared drive to a team drive and we have a google sheet script that uses the method
Session.getEffectiveUser().getEmail();
but I get this error when running the script
TypeError: Cannot call method "getEmail" of null.
It worked when the file was in or is in My drive but it doesn't work if it is in the Team Drive. I've also called it in the Logger in the script editor while the script is in the Team Drive and it returns the correct value. I've also tried this method.
Session.getActiveUser().getEmail();