diff --git a/lambda/index.js b/lambda/index.js index 3d24bef..9b46017 100644 --- a/lambda/index.js +++ b/lambda/index.js @@ -146,11 +146,9 @@ function extractUserFields(googleUser) { let phone = ""; if (googleUser.phones && googleUser.phones.length > 0) { - const workPhone = googleUser.phones.find((p) => p.type === "work"); - const primaryPhone = googleUser.phones.find((p) => p.primary) || googleUser.phones[0]; - phone = workPhone - ? workPhone.value - : primaryPhone.value || ""; + const workPhone = googleUser.phones.find((p) => p.type === "work" && p.value); + const primaryPhone = googleUser.phones.find((p) => p.primary && p.value) || googleUser.phones.find((p) => p.value); + phone = (workPhone || primaryPhone || {}).value || ""; } return { email, jobTitle, phone };