Skip to content

[Due for payment 2026-07-29] [$250] [Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction #95672

Closed

Description

@melvin-bot

Description

When a user on a private domain with a restricted submission security group uses the native iOS/Android share sheet to submit a receipt, the Submit tab displays all available workspaces — not just the one permitted by the security group. This bypasses the intended restriction.

Expected behavior

Users whose domain security group restricts submission to a specific workspace should only see that workspace as a destination in the share sheet Submit tab — matching the in-product experience.

Actual behavior

All workspaces are shown in the share sheet Submit tab, regardless of domain security group restrictions. The correct/restricted workspace is not even prioritized at the top of the list.

Steps to reproduce

  1. Be a member of a private domain with submission restricted to one workspace via security group settings.
  2. On iOS or Android, share an image/file using the native share sheet and open it in Expensify.
  3. Navigate to the Submit tab.
  4. Observe that all workspaces are listed as submission destinations.

Impact

Users can attempt to submit to workspaces outside their security group's restriction, breaking admin-enforced policy.

Notes

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    InternalRequires API changes or must be handled by Expensify staff
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 9, 2026
  2. added
    ExternalAdded to denote the issue can be worked on by a contributor
    and removed
    InternalRequires API changes or must be handled by Expensify staff
    on Jul 9, 2026
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 9, 2026
  4. melvin-bot commented on Jul 9, 2026

    @melvin-bot
    Author

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (External)

  5. melvin-bot commented on Jul 9, 2026

    @melvin-bot
    Author
  6. changed the title [-][Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction[/-] [+][$250] [Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction[/+] on Jul 9, 2026
  7. godzillaxbox19982014-lgtm commented on Jul 9, 2026

    @godzillaxbox19982014-lgtm

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    [Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction

    What is the root cause of that problem?

    I traced this to the path that handles the issue-specific state:

    • src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:263 (senderWorkspaceID): const senderWorkspaceID = transaction?.participants?.find((p) => p?.isSender)?.policyID;
    • src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:265 (existingInvoiceReport): const existingInvoiceReport = useParticipantsInvoiceReport(receiverAccountID, receiverType, senderWorkspaceID);
    • src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:243 (if): if (iouType === CONST.IOU.TYPE.SPLIT && transaction?.splitShares) {
    • The local evidence matches this recurring failure shape: optimistic transaction/report data is written to one Onyx key but the visible list reads another derived key. Here, src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:263 and src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:265 do not agree on the same the issue-specific state value, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.

    What changes do you think we should make in order to solve the problem?

    • Update src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:263 to derive the issue-specific state from the report/transaction source that owns this flow before the value is consumed.
    • Carry the same normalized value through src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:265; that follows the safer family move to align optimistic/success/failure data with the selector consumed by the screen, so the write/optimistic/read paths agree instead of only changing the visible component.
    • Keep the change inside the Reports, Expenses, IOU, Transactions surface and avoid changing payment actions, personal/deleted policies.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    1. Add or update a regression in tests/unit/ReportUtils*.ts for the exact issue flow: [Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction.
    2. Cover the counter-case near src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:263 so valid existing the issue-specific state behavior still works.
    3. Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.

    What alternative solutions did you explore? (Optional)

    • I would not add a broad new condition outside these referenced paths; the safer fix is to keep the issue-specific state consistent at the first read/write boundary shown above.
  8. samranahm commented on Jul 9, 2026

    @samranahm
    Contributor

    Proposal

    What is the root cause of that problem?

    When a receipt is shared through the native iOS/Android share sheet and the user opens the Submit tab, the destination list is populated from every workspace the user belongs to, without applying the domain security group restriction that the normal in-product create flow enforces. So a user whose security group limits submission to a single workspace still sees all of them.

    The share flow keeps the shared file and session context in Onyx via the Share action module, and the Submit tab reads the full set of active policies to build its destination options rather than the restricted set:

    function clearShareData() {
    Onyx.multiSet({
    [ONYXKEYS.SHARE_TEMP_FILE]: null,
    [ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS]: null,
    // Also clear any file validated in a previous share session. Otherwise a HEIC/`image/*` share
    // could reuse the previous session's validated file (which ShareDetailsPage uploads) during the
    // window before the new async validation overwrites VALIDATED_FILE_OBJECT.
    [ONYXKEYS.VALIDATED_FILE_OBJECT]: null,
    });
    }

    Because the Submit tab derives its workspace options straight from the unfiltered policy collection, the domain restriction that used to short circuit this flow (skip directly to confirmation with the locked workspace) is never applied. This is the regression called out in the issue and matches the same class of bug as #76179, where the domain-controlled workspace restriction was not carried into the quick-action/share flows.

    What changes do you think we should make in order to solve the problem?

    1. In the share Submit tab that builds the workspace destination list, filter the policy options through the same domain security group restriction helper the in-product create flow uses, so only the permitted workspace(s) are shown. The share session data that feeds this list is owned by the Share action module:

    function clearShareData() {
    Onyx.multiSet({
    [ONYXKEYS.SHARE_TEMP_FILE]: null,
    [ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS]: null,
    // Also clear any file validated in a previous share session. Otherwise a HEIC/`image/*` share
    // could reuse the previous session's validated file (which ShareDetailsPage uploads) during the
    // window before the new async validation overwrites VALIDATED_FILE_OBJECT.
    [ONYXKEYS.VALIDATED_FILE_OBJECT]: null,
    });
    }

    Concretely, before rendering the destination options, resolve the restricted workspace set and short circuit when it is a single locked workspace:

    const allowedPolicies = getAllowedSubmitPolicies(policies, currentUserLogin);
    const workspaceOptions = allowedPolicies;
    const lockedWorkspaceID = allowedPolicies.length === 1 ? allowedPolicies.at(0)?.id : undefined;
    1. When lockedWorkspaceID is defined, skip the workspace picker and route straight to the confirmation step with that workspace preselected, restoring the previous behavior described in the issue notes.

    2. Keep the restriction logic centralized in the existing policy restriction helper so the share Submit tab and the in-product create flow stay in sync and cannot diverge again.

    This fixes the root cause because the destination list is derived from the restricted policy set rather than the full policy collection, so the admin-enforced security group restriction is honored in the share sheet exactly as it is in the app.

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

    Solution Verification Result

    Before After
    BEFORE.mp4
    AFTER.mp4
  9. 63 remaining items

  10. melvin-bot commented on Jul 22, 2026

    @melvin-bot
    Author

    @daledah 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]

  11. daledah commented on Jul 23, 2026

    @daledah
    Contributor

    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

    • [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:

    • [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/666571

    Regression Test Proposal

    Test:

    1. Be a member of a private domain with submission restricted to one workspace via security group settings.
    2. On iOS or Android, share an image/file using the native share sheet and open it in Expensify.
    3. Verify that: user goes straight to the submit details page for the locked workspace

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-e3ae-a409-dda8-d63355fb6494
  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jul 23, 2026
  13. melvin-bot commented on Jul 28, 2026

    @melvin-bot
    Author

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Jul 28, 2026

    @melvin-bot
    Author

    Payment Summary

    Upwork Job

    • Reviewer: @daledah owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2075154567938633523/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  15. mallenexpensify commented on Jul 30, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @daledah due $250 via NewDot

  16. quinthar commented on Aug 19, 2026

    @quinthar
    Contributor

    Approved $250 to @daledah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions