You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-06-22] [$250] BA - Share button is visible for business bank account without workspace members #91834
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
There is a mismatch between the two functions that control (1) whether the Share button is visible and (2) which recipients appear on the share page.
The Share button visibility is gated by hasEligibleActiveAdminFromWorkspaces, which calls getActivePolicies — this returns all policies the user belongs to (any role). So if any admin exists in any workspace, the button appears.
The actual share page uses getEligibleBankAccountShareRecipients, which calls getActiveAdminWorkspaces — this returns only policies where the current user is an admin.
Neither function scopes its check to the specific workspace the bank account belongs to (accountData.additionalData.policyID). They both iterate across all of the user's workspaces.
This means:
The Share button can appear even when the user's only workspace has no other members (because another unrelated workspace has an admin).
The share list can show contacts from completely unrelated workspaces.
What changes do you think we should make in order to solve the problem?
Both hasEligibleActiveAdminFromWorkspaces and getEligibleBankAccountShareRecipients should be scoped to the bank account's workspace using its policyID (available via accountData.additionalData.policyID).
In hasEligibleActiveAdminFromWorkspaces (PolicyUtils.ts:359): change getActivePolicies to getActiveAdminWorkspaces (to match the share page), then filter the result to only the policy matching the bank account's policyID.
In getEligibleBankAccountShareRecipients (PolicyUtils.ts:318): filter activePolicies to only the policy matching the bank account's policyID.
This ensures the Share button only appears when there are other admins in the bank account's own workspace, and the share list only shows admins from that workspace.
What alternative solutions did you explore? (Optional)
An alternative is to only fix hasEligibleActiveAdminFromWorkspaces by switching it to use getActiveAdminWorkspaces (making both functions consistent) without scoping to policyID. This would fix the role mismatch but would still show admins from unrelated workspaces in the share list — so scoping to policyID is the more complete fix.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-05-27 12:29:24 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Wallet page, the three-dot menu of an open verified business bank account shows a "Share" entry even when the user's current admin workspace has no other members to share with. Opening the resulting share screen sometimes lists an Expensify contact that does not belong to any of the user's admin workspaces, which is the exact mismatch the tester flagged. The two surfaces disagree about who counts as an "eligible admin," which makes the entry point appear when the destination has nothing legitimate to offer.
What is the root cause of that problem?
The Share menu entry in WalletPage is gated by shouldShowShareButton && hasEligibleActiveAdmin. shouldShowShareButton only inspects bank-account properties (type === BUSINESS, state === OPEN, allowDebit) and never looks at workspace membership, so the "any workspace member to share with" decision is delegated entirely to hasEligibleActiveAdmin, which calls hasEligibleActiveAdminFromWorkspaces from PolicyUtils.
That helper iterates getActivePolicies(policies, currentUserLogin) — every policy the user has ANY role in (admin, user, or auditor) — and returns true as soon as it finds an admin who is not the current user and not already a sharee. The destination screen, ShareBankAccount, builds its recipient list from getEligibleBankAccountShareRecipients, which iterates getActiveAdminWorkspaces instead — restricted to policies where the current user is themselves an admin — and additionally drops admins without a getPersonalDetailByEmail entry. The two helpers therefore answer different questions:
Concretely, when the tester deletes their workspaces and creates a single new workspace with no other members, that new workspace's only admin is themselves (skipped by the email === currentUserLogin guard). But the user is still an employee/user/auditor of other people's policies that remain in the policies collection. Those policies survive getActivePolicies (any role qualifies) but are filtered out by getActiveAdminWorkspaces (admin role only). The button's gate sees the foreign admins and lights up; the share screen's list either omits them (different membership filter) or includes only stragglers whose policies happen to satisfy both filters but whose personal details are absent on the share screen anyway. Either way, the Share entry appears for a workspace that has no members to share with, which is exactly what the test plan forbids.
What changes do you think we should make in order to solve the problem?
Make hasEligibleActiveAdminFromWorkspaces answer the same question its sibling answers — "is there at least one admin we could actually surface on ShareBankAccount?" — by replacing getActivePolicies with getActiveAdminWorkspaces and adding the same getPersonalDetailByEmail guard that the recipient builder uses. Both functions then share one definition of eligibility: admins of policies the current user administers, excluding the current user, sharees already on the account, and emails without personal details.
hasEligibleActiveAdminFromWorkspaces has exactly one call site (WalletPage/index.tsx line 134), so tightening it cannot regress any other surface. The behavior for a workspace owner who has other admins in their workspace is unchanged: the loop still finds them and returns true. For the reported scenario — a sole admin in their own workspace, with no co-admins — the loop now correctly finds nothing and the menu hides Share. Equivalent state shapes already have unit coverage in tests/unit/PolicyUtilsTest.ts for getEligibleBankAccountShareRecipients; we should add the mirroring hasEligibleActiveAdminFromWorkspaces cases (no admin workspaces, only-self admin, eligible co-admin, already-shared sharee) so the two helpers stay locked together.
What alternative solutions did you explore? (Optional)
We considered gating the Share entry purely on getEligibleBankAccountShareRecipients(...).length > 0 inside WalletPage, which would guarantee parity by construction. We rejected it because that helper allocates a Map, calls formatMemberForList, and resolves personal details for every admin on every render of the wallet page, whereas the boolean helper short-circuits on the first eligible admin — important on accounts with many workspaces.
Two helpers in src/libs/PolicyUtils.ts decide both whether the Share row appears in the three‑dot menu and who shows up on the Share recipients page, but they aggregate admins across every workspace the current user belongs to instead of restricting to the workspace that owns the bank account (accountData.additionalData.policyID). For the QA scenario, the user has at least one other workspace from the precondition that wasn't deleted, and admins from that unrelated workspace flip the eligibility flag and populate the recipients list.
hasEligibleActiveAdminFromWorkspaces iterates all policies returned by getActivePolicies (any role) and returns true as soon as it finds an admin in any workspace whose email ≠ current user — the bank account's owning policy is never consulted:
Tapping Share opens ShareBankAccount, which calls getEligibleBankAccountShareRecipients. That function uses getActiveAdminWorkspaces (every workspace the user is admin in), still ignores accountData.additionalData.policyID, and returns admins from any unrelated admin workspace — that is the "Expensify contact that does not belong to any workspace" the tester sees:
Concrete walk‑through for the repro (user is the only admin of the workspace tied to the BA, but still admin of/member of one leftover workspace W2 with admin bob@expensifail.com):
getActivePolicies(allPolicies, me) → [W_new, W2].
getAdminEmployees(W_new) → [me] → filtered out by email === currentUserLogin.
Tapping Share calls getEligibleBankAccountShareRecipients → getActiveAdminWorkspaces returns [W_new, W2] (admin in both) → admins of W2 get added to the list → bob appears in the share sheet even though the bank account is owned by W_new (step 7 fails).
Expected behavior per the Bug Report — "Share button should not be visible when the workspace has no other members" — only holds if both helpers scope themselves to the bank account's owning policy. Today neither does.
What changes in code
src/libs/PolicyUtils.ts — restrict both helpers to the bank account's owning policy (and require the current user to be admin of that policy, since the Share feature is admin‑only):
function getEligibleBankAccountShareRecipients(policies: OnyxCollection<Policy> | null, currentUserLogin: string | undefined, bankAccountID: string | undefined): MemberForList[] {
const currentBankAccount = getBankAccountFromID(Number(bankAccountID));
- const activePolicies = getActiveAdminWorkspaces(policies, currentUserLogin);- if (!activePolicies) {+ const ownerPolicyID = currentBankAccount?.accountData?.additionalData?.policyID;+ const ownerPolicy = ownerPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${ownerPolicyID}`] : undefined;+ if (!ownerPolicy || !isPolicyAdmin(ownerPolicy, currentUserLogin)) {
return [];
}
const adminMap = new Map<string, MemberForList>();
- // O(1) checks for already-shared emails
const shareesSet = new Set(currentBankAccount?.accountData?.sharees ?? []);
- for (const policy of Object.values(activePolicies)) {- for (const admin of getAdminEmployees(policy)) {- const email = admin?.email;- if (!email || email === currentUserLogin || adminMap.has(email) || shareesSet.has(email)) {- continue;- }- const personalDetails = getPersonalDetailByEmail(email);- if (!personalDetails) {- continue;- }- adminMap.set(email, formatMemberForList({ … }));- }+ for (const admin of getAdminEmployees(ownerPolicy)) {+ const email = admin?.email;+ if (!email || email === currentUserLogin || adminMap.has(email) || shareesSet.has(email)) {+ continue;+ }+ const personalDetails = getPersonalDetailByEmail(email);+ if (!personalDetails) {+ continue;+ }+ adminMap.set(email, formatMemberForList({ … }));
}
return Array.from(adminMap.values());
}
function hasEligibleActiveAdminFromWorkspaces(policies: OnyxCollection<Policy> | null, currentUserLogin: string | undefined, bankAccountID: string | undefined): boolean {
const currentBankAccount = getBankAccountFromID(Number(bankAccountID));
- const activePolicies = getActivePolicies(policies, currentUserLogin);- if (!activePolicies) {+ const ownerPolicyID = currentBankAccount?.accountData?.additionalData?.policyID;+ const ownerPolicy = ownerPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${ownerPolicyID}`] : undefined;+ if (!ownerPolicy || !isPolicyAdmin(ownerPolicy, currentUserLogin)) {
return false;
}
const alreadySharedSharees = new Set(currentBankAccount?.accountData?.sharees ?? []);
- for (const policy of Object.values(activePolicies)) {- const admins = getAdminEmployees(policy);- for (const admin of admins) {- const email = admin?.email;- if (!email || email === currentUserLogin || alreadySharedSharees.has(email)) {- continue;- }- return true;- }+ for (const admin of getAdminEmployees(ownerPolicy)) {+ const email = admin?.email;+ if (!email || email === currentUserLogin || alreadySharedSharees.has(email)) {+ continue;+ }+ return true;
}
return false;
}
After this change:
Step 6 (Share button visible): getAdminEmployees(W_new) returns only the current user → filter skips self → hasEligibleActiveAdminFromWorkspaces returns false → shouldShowShareButton && hasEligibleActiveAdmin evaluates true && false → the Share row is omitted from the three‑dot menu. ✅
Step 7 (unrelated contact appears): even if Share were somehow opened, getEligibleBankAccountShareRecipients now only looks at W_new's admins → empty list → empty‑state ("No admins available") instead of an unrelated contact. ✅
Happy path preserved: if W_new actually has another admin, getAdminEmployees(W_new) returns them → Share row shows → recipients page lists them. No change for the working case.
No changes needed in src/pages/settings/Wallet/WalletPage/index.tsx (the gating expression shouldShowShareButton && hasEligibleActiveAdmin is already correct — only the helper's policy scope was wrong) or in src/pages/settings/Wallet/ShareBankAccount/ShareBankAccount.tsx (it just consumes the corrected helper). import ONYXKEYS from '@src/ONYXKEYS' is already present in PolicyUtils.ts.
Alternatives
Just align hasEligibleActiveAdminFromWorkspaces to use getActiveAdminWorkspaces (matching the sibling helper). Rejected because it only fixes step 6 in the narrow case of "user is admin of nothing besides W_new". The reporter's "Expensify contact that does not belong to any workspace" symptom comes from step 7's getEligibleBankAccountShareRecipients also being workspace‑agnostic — if the user is admin of W_new and any other workspace W2, admins of W2 still leak into the share sheet.
Gate the Share row on accountData.sharees being non‑empty. Rejected — sharees is the already‑shared list, not eligibility. A freshly created business BA always has empty sharees, so this would permanently hide Share even when the workspace does have other admins.
Filter getAdminEmployees to admins present in personalDetails. Rejected — getEligibleBankAccountShareRecipients already does a getPersonalDetailByEmail check; the bug is the policy set the helpers iterate, not the personalDetails lookup. The unrelated admin shows up precisely because they are in personalDetails (they're a real Expensify user the current user has interacted with).
changed the title [-]BA - Share button is visible for business bank account without workspace members[/-][+][$250] BA - Share button is visible for business bank account without workspace members[/+]on May 27, 2026
Please re-state the problem that we are trying to solve in this issue.
On Web, when a user has a workspace with no other members and an open verified business bank account, the three-dot menu on that bank account shows a "Share" button (and the share list shows an Expensify contact that does not belong to any workspace). Expected: the Share button should be hidden when there is no eligible non-Expensify admin to share with.
What is the root cause of that problem?
A freshly created workspace's employeeList contains an auto-added Expensify system account with the admin role. In src/libs/PolicyUtils.ts:359hasEligibleActiveAdminFromWorkspaces iterates getAdminEmployees(policy) and only skips the current user and already-shared sharees (email === currentUserLogin || alreadySharedSharees.has(email)), so the system admin counts as eligible and the function returns true, making shouldShowShareButton && hasEligibleActiveAdmin true in src/pages/settings/Wallet/WalletPage/index.tsx:494. The same gap at src/libs/PolicyUtils.ts:318getEligibleBankAccountShareRecipients lets that Expensify account appear in the share list. Neither filters out CONST.EXPENSIFY_EMAILS, unlike the analogous getIneligibleInvitees (src/libs/PolicyUtils.ts:674-688).
What changes do you think we should make in order to solve the problem?
src/libs/PolicyUtils.ts:371 — in hasEligibleActiveAdminFromWorkspaces, extend the skip condition so Expensify system accounts are excluded, e.g. also continue when CONST.EXPENSIFY_EMAILS.includes(email) (mirroring getIneligibleInvitees). This makes the function return false for a workspace whose only non-current-user admin is an Expensify account, hiding the Share button.
src/libs/PolicyUtils.ts:331 — apply the identical exclusion in getEligibleBankAccountShareRecipients's skip condition, so the Expensify contact no longer appears in the share recipient list.
Optionally factor the exclusion into a small shared predicate so both call sites stay in sync.
What alternative solutions did you explore? (Optional)
Gating the button on workspace member count instead of admin eligibility — rejected because the real defect is treating the Expensify system admin as a shareable recipient, which member-count checks wouldn't fix in the share list itself.
⚠️@yusufdeveloper2903 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
@FitseTLT / @bernhardoj The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A
Link to the comment on the Issue: N/A
Not a regression. The code has been implemented that way since its initial implementation.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
applause-bot commentedon May 27, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/7ed96b7c8748c9a7f6e8b800107373903fd6f0e77bc28e84ef63ec106d2ee71a
MelvinBot commentedon May 27, 2026
Proposal
What is the root cause of that problem?
There is a mismatch between the two functions that control (1) whether the Share button is visible and (2) which recipients appear on the share page.
The Share button visibility is gated by
hasEligibleActiveAdminFromWorkspaces, which callsgetActivePolicies— this returns all policies the user belongs to (any role). So if any admin exists in any workspace, the button appears.The actual share page uses
getEligibleBankAccountShareRecipients, which callsgetActiveAdminWorkspaces— this returns only policies where the current user is an admin.Neither function scopes its check to the specific workspace the bank account belongs to (
accountData.additionalData.policyID). They both iterate across all of the user's workspaces.This means:
Code references
WalletPage/index.tsx:494-506shouldShowShareButtonset based only on account type/state/allowDebit (no workspace check):WalletPage/index.tsx:180hasEligibleActiveAdminusesgetActivePolicies(all roles):PolicyUtils.ts:361getEligibleBankAccountShareRecipientsusesgetActiveAdminWorkspaces(admin only):PolicyUtils.ts:320What changes do you think we should make in order to solve the problem?
Both
hasEligibleActiveAdminFromWorkspacesandgetEligibleBankAccountShareRecipientsshould be scoped to the bank account's workspace using itspolicyID(available viaaccountData.additionalData.policyID).hasEligibleActiveAdminFromWorkspaces(PolicyUtils.ts:359): changegetActivePoliciestogetActiveAdminWorkspaces(to match the share page), then filter the result to only the policy matching the bank account'spolicyID.getEligibleBankAccountShareRecipients(PolicyUtils.ts:318): filteractivePoliciesto only the policy matching the bank account'spolicyID.This ensures the Share button only appears when there are other admins in the bank account's own workspace, and the share list only shows admins from that workspace.
What alternative solutions did you explore? (Optional)
An alternative is to only fix
hasEligibleActiveAdminFromWorkspacesby switching it to usegetActiveAdminWorkspaces(making both functions consistent) without scoping topolicyID. This would fix the role mismatch but would still show admins from unrelated workspaces in the share list — so scoping topolicyIDis the more complete fix.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.MobileMage commentedon May 27, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-27 12:29:24 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Wallet page, the three-dot menu of an open verified business bank account shows a "Share" entry even when the user's current admin workspace has no other members to share with. Opening the resulting share screen sometimes lists an Expensify contact that does not belong to any of the user's admin workspaces, which is the exact mismatch the tester flagged. The two surfaces disagree about who counts as an "eligible admin," which makes the entry point appear when the destination has nothing legitimate to offer.
What is the root cause of that problem?
The Share menu entry in
WalletPageis gated byshouldShowShareButton && hasEligibleActiveAdmin.shouldShowShareButtononly inspects bank-account properties (type === BUSINESS,state === OPEN,allowDebit) and never looks at workspace membership, so the "any workspace member to share with" decision is delegated entirely tohasEligibleActiveAdmin, which callshasEligibleActiveAdminFromWorkspacesfromPolicyUtils.App/src/pages/settings/Wallet/WalletPage/index.tsx
Lines 494 to 508 in cd9d85c
That helper iterates
getActivePolicies(policies, currentUserLogin)— every policy the user has ANY role in (admin, user, or auditor) — and returnstrueas soon as it finds an admin who is not the current user and not already a sharee. The destination screen,ShareBankAccount, builds its recipient list fromgetEligibleBankAccountShareRecipients, which iteratesgetActiveAdminWorkspacesinstead — restricted to policies where the current user is themselves an admin — and additionally drops admins without agetPersonalDetailByEmailentry. The two helpers therefore answer different questions:App/src/libs/PolicyUtils.ts
Lines 359 to 380 in cd9d85c
Concretely, when the tester deletes their workspaces and creates a single new workspace with no other members, that new workspace's only admin is themselves (skipped by the
email === currentUserLoginguard). But the user is still an employee/user/auditor of other people's policies that remain in thepoliciescollection. Those policies survivegetActivePolicies(any role qualifies) but are filtered out bygetActiveAdminWorkspaces(admin role only). The button's gate sees the foreign admins and lights up; the share screen's list either omits them (different membership filter) or includes only stragglers whose policies happen to satisfy both filters but whose personal details are absent on the share screen anyway. Either way, the Share entry appears for a workspace that has no members to share with, which is exactly what the test plan forbids.What changes do you think we should make in order to solve the problem?
Make
hasEligibleActiveAdminFromWorkspacesanswer the same question its sibling answers — "is there at least one admin we could actually surface onShareBankAccount?" — by replacinggetActivePolicieswithgetActiveAdminWorkspacesand adding the samegetPersonalDetailByEmailguard that the recipient builder uses. Both functions then share one definition of eligibility: admins of policies the current user administers, excluding the current user, sharees already on the account, and emails without personal details.App/src/libs/PolicyUtils.ts
Lines 318 to 353 in cd9d85c
hasEligibleActiveAdminFromWorkspaceshas exactly one call site (WalletPage/index.tsxline 134), so tightening it cannot regress any other surface. The behavior for a workspace owner who has other admins in their workspace is unchanged: the loop still finds them and returnstrue. For the reported scenario — a sole admin in their own workspace, with no co-admins — the loop now correctly finds nothing and the menu hides Share. Equivalent state shapes already have unit coverage intests/unit/PolicyUtilsTest.tsforgetEligibleBankAccountShareRecipients; we should add the mirroringhasEligibleActiveAdminFromWorkspacescases (no admin workspaces, only-self admin, eligible co-admin, already-shared sharee) so the two helpers stay locked together.What alternative solutions did you explore? (Optional)
We considered gating the Share entry purely on
getEligibleBankAccountShareRecipients(...).length > 0insideWalletPage, which would guarantee parity by construction. We rejected it because that helper allocates aMap, callsformatMemberForList, and resolves personal details for every admin on every render of the wallet page, whereas the boolean helper short-circuits on the first eligible admin — important on accounts with many workspaces.yusufdeveloper2903 commentedon May 27, 2026
Root Cause
Two helpers in
src/libs/PolicyUtils.tsdecide both whether the Share row appears in the three‑dot menu and who shows up on the Share recipients page, but they aggregate admins across every workspace the current user belongs to instead of restricting to the workspace that owns the bank account (accountData.additionalData.policyID). For the QA scenario, the user has at least one other workspace from the precondition that wasn't deleted, and admins from that unrelated workspace flip the eligibility flag and populate the recipients list.Trace at https://github.com/Expensify/App/blob/cd9d85cba920329f84bfdd8d163173d56d46a6f2 :
WalletPagecomputeshasEligibleActiveAdminand gates the Share menu row on it:App/src/pages/settings/Wallet/WalletPage/index.tsx
Lines 494 to 508 in cd9d85c
App/src/pages/settings/Wallet/WalletPage/index.tsx
Line 134 in cd9d85c
hasEligibleActiveAdminFromWorkspacesiterates all policies returned bygetActivePolicies(any role) and returnstrueas soon as it finds an admin in any workspace whose email ≠ current user — the bank account's owning policy is never consulted:App/src/libs/PolicyUtils.ts
Lines 359 to 380 in cd9d85c
ShareBankAccount, which callsgetEligibleBankAccountShareRecipients. That function usesgetActiveAdminWorkspaces(every workspace the user is admin in), still ignoresaccountData.additionalData.policyID, and returns admins from any unrelated admin workspace — that is the "Expensify contact that does not belong to any workspace" the tester sees:App/src/libs/PolicyUtils.ts
Lines 318 to 354 in cd9d85c
Concrete walk‑through for the repro (user is the only admin of the workspace tied to the BA, but still admin of/member of one leftover workspace
W2with adminbob@expensifail.com):getActivePolicies(allPolicies, me)→[W_new, W2].getAdminEmployees(W_new)→[me]→ filtered out byemail === currentUserLogin.getAdminEmployees(W2)→[bob, …]→ first non‑self admin →hasEligibleActiveAdmin = true→ Share row renders (step 6 fails).getEligibleBankAccountShareRecipients→getActiveAdminWorkspacesreturns[W_new, W2](admin in both) → admins ofW2get added to the list →bobappears in the share sheet even though the bank account is owned byW_new(step 7 fails).Expected behavior per the Bug Report — "Share button should not be visible when the workspace has no other members" — only holds if both helpers scope themselves to the bank account's owning policy. Today neither does.
What changes in code
src/libs/PolicyUtils.ts— restrict both helpers to the bank account's owning policy (and require the current user to be admin of that policy, since the Share feature is admin‑only):function getEligibleBankAccountShareRecipients(policies: OnyxCollection<Policy> | null, currentUserLogin: string | undefined, bankAccountID: string | undefined): MemberForList[] { const currentBankAccount = getBankAccountFromID(Number(bankAccountID)); - const activePolicies = getActiveAdminWorkspaces(policies, currentUserLogin); - if (!activePolicies) { + const ownerPolicyID = currentBankAccount?.accountData?.additionalData?.policyID; + const ownerPolicy = ownerPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${ownerPolicyID}`] : undefined; + if (!ownerPolicy || !isPolicyAdmin(ownerPolicy, currentUserLogin)) { return []; } const adminMap = new Map<string, MemberForList>(); - // O(1) checks for already-shared emails const shareesSet = new Set(currentBankAccount?.accountData?.sharees ?? []); - for (const policy of Object.values(activePolicies)) { - for (const admin of getAdminEmployees(policy)) { - const email = admin?.email; - if (!email || email === currentUserLogin || adminMap.has(email) || shareesSet.has(email)) { - continue; - } - const personalDetails = getPersonalDetailByEmail(email); - if (!personalDetails) { - continue; - } - adminMap.set(email, formatMemberForList({ … })); - } + for (const admin of getAdminEmployees(ownerPolicy)) { + const email = admin?.email; + if (!email || email === currentUserLogin || adminMap.has(email) || shareesSet.has(email)) { + continue; + } + const personalDetails = getPersonalDetailByEmail(email); + if (!personalDetails) { + continue; + } + adminMap.set(email, formatMemberForList({ … })); } return Array.from(adminMap.values()); } function hasEligibleActiveAdminFromWorkspaces(policies: OnyxCollection<Policy> | null, currentUserLogin: string | undefined, bankAccountID: string | undefined): boolean { const currentBankAccount = getBankAccountFromID(Number(bankAccountID)); - const activePolicies = getActivePolicies(policies, currentUserLogin); - if (!activePolicies) { + const ownerPolicyID = currentBankAccount?.accountData?.additionalData?.policyID; + const ownerPolicy = ownerPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${ownerPolicyID}`] : undefined; + if (!ownerPolicy || !isPolicyAdmin(ownerPolicy, currentUserLogin)) { return false; } const alreadySharedSharees = new Set(currentBankAccount?.accountData?.sharees ?? []); - for (const policy of Object.values(activePolicies)) { - const admins = getAdminEmployees(policy); - for (const admin of admins) { - const email = admin?.email; - if (!email || email === currentUserLogin || alreadySharedSharees.has(email)) { - continue; - } - return true; - } + for (const admin of getAdminEmployees(ownerPolicy)) { + const email = admin?.email; + if (!email || email === currentUserLogin || alreadySharedSharees.has(email)) { + continue; + } + return true; } return false; }After this change:
getAdminEmployees(W_new)returns only the current user → filter skips self →hasEligibleActiveAdminFromWorkspacesreturnsfalse→shouldShowShareButton && hasEligibleActiveAdminevaluatestrue && false→ the Share row is omitted from the three‑dot menu. ✅getEligibleBankAccountShareRecipientsnow only looks atW_new's admins → empty list → empty‑state ("No admins available") instead of an unrelated contact. ✅W_newactually has another admin,getAdminEmployees(W_new)returns them → Share row shows → recipients page lists them. No change for the working case.No changes needed in
src/pages/settings/Wallet/WalletPage/index.tsx(the gating expressionshouldShowShareButton && hasEligibleActiveAdminis already correct — only the helper's policy scope was wrong) or insrc/pages/settings/Wallet/ShareBankAccount/ShareBankAccount.tsx(it just consumes the corrected helper).import ONYXKEYS from '@src/ONYXKEYS'is already present inPolicyUtils.ts.Alternatives
hasEligibleActiveAdminFromWorkspacesto usegetActiveAdminWorkspaces(matching the sibling helper). Rejected because it only fixes step 6 in the narrow case of "user is admin of nothing besidesW_new". The reporter's "Expensify contact that does not belong to any workspace" symptom comes from step 7'sgetEligibleBankAccountShareRecipientsalso being workspace‑agnostic — if the user is admin ofW_newand any other workspaceW2, admins ofW2still leak into the share sheet.accountData.shareesbeing non‑empty. Rejected —shareesis the already‑shared list, not eligibility. A freshly created business BA always has emptysharees, so this would permanently hide Share even when the workspace does have other admins.getAdminEmployeesto admins present inpersonalDetails. Rejected —getEligibleBankAccountShareRecipientsalready does agetPersonalDetailByEmailcheck; the bug is the policy set the helpers iterate, not the personalDetails lookup. The unrelated admin shows up precisely because they are inpersonalDetails(they're a real Expensify user the current user has interacted with).melvin-bot commentedon May 27, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @bernhardoj (
External)[-]BA - Share button is visible for business bank account without workspace members[/-][+][$250] BA - Share button is visible for business bank account without workspace members[/+]melvin-bot commentedon May 27, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022059612318293552552
aswin-s commentedon May 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, when a user has a workspace with no other members and an open verified business bank account, the three-dot menu on that bank account shows a "Share" button (and the share list shows an Expensify contact that does not belong to any workspace). Expected: the Share button should be hidden when there is no eligible non-Expensify admin to share with.
What is the root cause of that problem?
A freshly created workspace's
employeeListcontains an auto-added Expensify system account with the admin role. Insrc/libs/PolicyUtils.ts:359hasEligibleActiveAdminFromWorkspacesiteratesgetAdminEmployees(policy)and only skips the current user and already-shared sharees (email === currentUserLogin || alreadySharedSharees.has(email)), so the system admin counts as eligible and the function returnstrue, makingshouldShowShareButton && hasEligibleActiveAdmintrue insrc/pages/settings/Wallet/WalletPage/index.tsx:494. The same gap atsrc/libs/PolicyUtils.ts:318getEligibleBankAccountShareRecipientslets that Expensify account appear in the share list. Neither filters outCONST.EXPENSIFY_EMAILS, unlike the analogousgetIneligibleInvitees(src/libs/PolicyUtils.ts:674-688).What changes do you think we should make in order to solve the problem?
src/libs/PolicyUtils.ts:371— inhasEligibleActiveAdminFromWorkspaces, extend the skip condition so Expensify system accounts are excluded, e.g. alsocontinuewhenCONST.EXPENSIFY_EMAILS.includes(email)(mirroringgetIneligibleInvitees). This makes the function returnfalsefor a workspace whose only non-current-user admin is an Expensify account, hiding the Share button.src/libs/PolicyUtils.ts:331— apply the identical exclusion ingetEligibleBankAccountShareRecipients's skip condition, so the Expensify contact no longer appears in the share recipient list.What alternative solutions did you explore? (Optional)
Gating the button on workspace member count instead of admin eligibility — rejected because the real defect is treating the Expensify system admin as a shareable recipient, which member-count checks wouldn't fix in the share list itself.
github-actions commentedon May 27, 2026
59 remaining items
melvin-bot commentedon Jun 15, 2026
@FitseTLT / @bernhardoj The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
bernhardoj commentedon Jun 16, 2026
BugZero Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A
Link to the comment on the Issue: N/A
Not a regression. The code has been implemented that way since its initial implementation.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/651119
Regression Test Proposal
Precondition:
@team.expensify.comdomain as an admin to one workspace (the member will be hidden)Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-c2d2-aada-1a71-7a89ba306094melvin-bot commentedon Jun 21, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon Jun 22, 2026
Payment Summary
Contributor: @FitseTLT due $250 via NewDot
Contributor+: @bernhardoj due $250 via NewDot
^ Test case created. Thx
flaviadefaria commentedon Jun 30, 2026
Approved: @bernhardoj due $250 via NewDot
flaviadefaria commentedon Jul 29, 2026
Approved: @FitseTLT due $250 via NewDot