From 5b8f6f83be2faa327f613b5a523a16eb4d4a47f9 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Thu, 13 Nov 2025 06:51:56 -0800 Subject: [PATCH] Assume users are in enterprise commons if v1 affiliates lookup fails (#22728) * updating affiliation check for enterprise commons to default to restricting wf on error * feat: simplify logic on affiliate lookup failure GitOrigin-RevId: ccd676af9a44413bf63fe7c1f7836080c2612f45 --- .../Features/Project/ProjectController.mjs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.mjs b/services/web/app/src/Features/Project/ProjectController.mjs index 26c709b6d3..58fab31622 100644 --- a/services/web/app/src/Features/Project/ProjectController.mjs +++ b/services/web/app/src/Features/Project/ProjectController.mjs @@ -488,7 +488,10 @@ const _ProjectController = { affiliations: InstitutionsGetter.promises .getCurrentAffiliations(userId) .catch(err => { - logger.error({ err, userId }, 'failed to get institution licence') + logger.error( + { err, userId }, + 'failed to get current affiliations' + ) return false }), subscription: @@ -1216,12 +1219,15 @@ const _ProjectController = { aiFeaturesAllowed, userIsMemberOfGroupSubscription ) { - let inEnterpriseCommons = false - const affiliations = userValues.affiliations || [] - for (const affiliation of affiliations) { - inEnterpriseCommons = - inEnterpriseCommons || affiliation.institution?.enterpriseCommons - } + const affiliations = userValues.affiliations + const affiliateLookupFailed = affiliations === false + + // if affiliations is specifically false instead of empty, we know the affiliate lookup failed, and should defer to blocking auto-loading + const inEnterpriseCommons = + affiliateLookupFailed || + affiliations.some( + affiliation => affiliation.institution?.enterpriseCommons + ) // check if a user has never tried writefull before (writefull.enabled will be null) // if they previously accepted writefull, or are have been already assigned to a trial, user.writefull will be true,