Context: this is not a request for help, I found the solution, I just want to understand why.
Working code:
var username_result = (await googleSheets.spreadsheets.values.get({
auth,
spreadsheetId,
range: "users!A" + selrow,
})).data;
This returns the expected object, and I can log it to console to view its contents.
If I remove the outer set of parentheses, i.e. making this not an IIFE, username_result is undefined.
I read through this question and it seems to suggest that googleSheets.spreadsheets.values.get({}).data would otherwise not return any value if not wrapped as an IIFE. I looked at the documentation for this function and it explicitly states that it returns a range of values.
I hate implementing code that I don't fully understand. Why does this need to be an IIFE to work?