For unkown reasons in Google Workspace the legacy thread id is set, but the new one not:
I suggest adding a fallback like this to the function:
api.new.get.thread_id = function() {
const threadElem = document.querySelector("[data-thread-perm-id]");
if (!threadElem) {
return null;
}
const threadPermId = threadElem.dataset["threadPermId"];
// Fall back to legacy thread ID if perm ID is undefined or the string "undefined"
if (!threadPermId || threadPermId === "undefined") {
return threadElem.dataset["legacyThreadId"] || null;
}
return threadPermId;
};