fix: Fall back to isPolicyAdmin when adminAccess is undefined for domain-level feeds#86281
fix: Fall back to isPolicyAdmin when adminAccess is undefined for domain-level feeds#86281Amsamms wants to merge 1 commit intoExpensify:mainfrom
Conversation
…ain-level feeds When adminAccess hasn't been loaded from the server yet (user hasn't visited the Domain settings page), the hook treats undefined as false and silently blocks card assignment. This adds a fallback to isPolicyAdmin for the undefined case, which is safe because the server validates domain admin access on the actual AssignCompanyCard API call. Fixes Expensify#86277
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3496607e3a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (adminAccess === undefined) { | ||
| return isPolicyAdmin; |
There was a problem hiding this comment.
Avoid granting domain access when admin state is unknown
When adminAccess is undefined, this fallback returns isPolicyAdmin, which lets any workspace admin pass the client-side permission check for domain feeds before domain membership is loaded. In useAssignCard, that value controls isAssigningCardDisabled, so a workspace admin who is not a domain admin can enter the assign-card flow and only fail later on API write, creating a false-authorized UX path. Keep the permission as denied/loading until domain admin access is explicitly known for that domain feed.
Useful? React with 👍 / 👎.
Explanation of Change
When a workspace admin navigates to Workspace > Company Cards and clicks "Assign Card" on a domain-level card feed (e.g., Chase), the action silently fails because
adminAccessfromSHARED_NVP_PRIVATE_ADMIN_ACCESShasn't been loaded into Onyx (it's only populated when the user visits the Domain settings page).This PR adds a fallback in
useIsAllowedToIssueCompanyCard— whenadminAccessisundefined(not yet loaded), it falls back toisPolicyAdmininstead of treating it asfalse. This is safe because:AssignCompanyCardAPI call validates admin permissions server-sideisPolicyAdministrueand the action proceeds correctlytrue/falsevalue takes overFixed Issues
$ #86277
PROPOSAL: #86277 (comment)
Linked issue: https://github.com/Expensify/Expensify/issues/615675
Tests
Offline tests
QA Steps
SHARED_NVP_PRIVATE_ADMIN_ACCESSis not cachedPR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssection