[$250] [Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction
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
- Be a member of a private domain with submission restricted to one workspace via security group settings.
- On iOS or Android, share an image/file using the native share sheet and open it in Expensify.
- Navigate to the Submit tab.
- 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
- This is a regression — the correct behavior (skip directly to confirmation with the locked workspace on the Submit tab) was previously working.
- Related closed issue: #76179 (same root cause: domain-controlled workspace restriction not applied to quick-action/share flows).
- Regression tests should be added to prevent recurrence.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022075154567938633523
- Upwork Job ID: 2075154567938633523
- Last Price Increase: 2026-07-09
Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (External)
Job added to Upwork: https://www.upwork.com/jobs/~022075154567938633523
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:263andsrc/pages/iou/request/step/confirmation/useExpenseSubmission.ts:265do not agree on the samethe issue-specific statevalue, 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:263to derivethe issue-specific statefrom 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?
- Add or update a regression in
tests/unit/ReportUtils*.tsfor the exact issue flow: [Bug] Native Share Sheet (Submit tab) shows all workspaces instead of respecting domain security group restriction. - Cover the counter-case near
src/pages/iou/request/step/confirmation/useExpenseSubmission.ts:263so valid existingthe issue-specific statebehavior still works. - 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 stateconsistent at the first read/write boundary shown above.
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:
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/libs/actions/Share.ts#L11-L20
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?
- 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
Shareaction module:
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/libs/actions/Share.ts#L11-L20
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;
-
When
lockedWorkspaceIDis 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. -
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 |
|---|---|
|
https://github.com/user-attachments/assets/acea449f-bc2b-44b5-861f-c989cbce233b |
https://github.com/user-attachments/assets/93447784-f4b8-49ef-8f3c-3c8b2e7a64a1 |
Proposal
What is the root cause of that problem?
The share sheet Submit tab uses the old generic participant selection entry point and does not apply the restricted preferred workspace shortcut that already exists for similar SmartScan/global-create flows.
ShareTabParticipantsSelector always renders MoneyRequestParticipantsSelector and only navigates after the user picks a participant:
https://github.com/Expensify/App/blob/be792a80f79ba5adf74162aaf84fc31afab12eec/src/components/Share/ShareTabParticipantsSelector.tsx#L42-L85
That selector receives iouType={CONST.IOU.TYPE.SUBMIT} and action="create", but it never pre-resolves the locked policy expense chat. So the share extension starts from “choose destination” instead of “use the only allowed destination”.
The similar bug in #76179 was fixed by making useDefaultExpensePolicy() return the domain security group’s preferred policy first:
https://github.com/Expensify/App/pull/76477
https://github.com/Expensify/App/commit/19e306e802436d155b909ab07622d64ff824d3ed
Current code still has that protection: https://github.com/Expensify/App/blob/be792a80f79ba5adf74162aaf84fc31afab12eec/src/hooks/useDefaultExpensePolicy.tsx#L39-L52
And the SmartScan/global-create path consumes it before opening the participant selector: https://github.com/Expensify/App/blob/be792a80f79ba5adf74162aaf84fc31afab12eec/src/pages/iou/request/step/IOURequestStepScan/components/NavigateGlobalCreateContext.tsx#L87-L101
But the native share sheet flow was added/updated separately in PR #88095 and only updated SubmitDetailsPage, not the SubmitTab -> ShareTabParticipantsSelector entry point:
https://github.com/Expensify/App/pull/88095
https://github.com/Expensify/App/commit/d51d4e4546e7328012bfd579579f0765d9559371
So the regression is a missed parity case: the share sheet Submit entry point bypasses the already-fixed preferred-policy defaulting logic.
What changes do you think we should make in order to solve the problem?
Apply the same default-policy shortcut at the share Submit entry point, before rendering the participant selector.
Keep the change scoped to ShareTabParticipantsSelector so normal Share tab behavior, unknown-user handling, and unrestricted users continue using the existing selector.
Small diff sketch:
+import useDefaultExpensePolicy from '@hooks/useDefaultExpensePolicy';
+import {getPolicyExpenseChat} from '@libs/ReportUtils';
function ShareTabParticipantsSelectorComponent({detailsPageRouteObject}: ShareTabParticipantsSelectorProps) {
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
+ const defaultExpensePolicy = useDefaultExpensePolicy();
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [selectedReportID, setSelectedReportID] = useState<string | number | undefined>();
const isSubmitFlow = detailsPageRouteObject === ROUTES.SHARE_SUBMIT_DETAILS;
+ const defaultPolicyExpenseChat = isSubmitFlow && defaultExpensePolicy?.id
+ ? getPolicyExpenseChat(currentUserAccountID, defaultExpensePolicy.id)
+ : undefined;
+
+ useEffect(() => {
+ if (!isSubmitFlow || !defaultPolicyExpenseChat?.reportID) {
+ return;
+ }
+ setSelectedReportID(defaultPolicyExpenseChat.reportID);
+ Navigation.navigate(detailsPageRouteObject.getRoute(defaultPolicyExpenseChat.reportID));
+ }, [isSubmitFlow, defaultPolicyExpenseChat?.reportID, detailsPageRouteObject]);
+
+ if (isSubmitFlow && defaultPolicyExpenseChat?.reportID) {
+ return null;
+ }
return (
<MoneyRequestParticipantsSelector
To avoid regressions:
- Only auto-navigate when
isSubmitFlowis true. - Only use a valid policy expense chat report ID.
- Leave unrestricted users on the current participant selector.
- Leave the Share tab unchanged.
- Keep the existing
onParticipantsAddedlogic for manually selected participants and unknown users. - Preserve existing telemetry by starting/updating
SPAN_SHARE_EXTENSION_OPEN_SUBMIT_FLOWfor the auto-selected report, same as manual selection.
https://github.com/user-attachments/assets/9e11cd30-4156-4930-a3e6-0986415187cf
https://github.com/user-attachments/assets/b62e9d7c-4d6b-493c-ae11-c1278d6abb09
⚠️ @mukhrr Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 10:00:23 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user's domain security group restricts submission to a single workspace, sharing a receipt through the native iOS/Android share sheet and opening the Submit tab shows the full workspace picker instead of taking them straight to confirmation on the locked workspace. The restricted workspace isn't even prioritized in the list, so the admin-enforced restriction is bypassed. This is a regression: the "skip the picker → land on the locked workspace" behavior exists for the in-product submit flow (added in #76179) but was never wired into the share-sheet Submit entry point.
What is the root cause of that problem?
The share Submit tab is the one submit entry point that never applies the domain-restriction short-circuit that every other submit entry point got in #76179.
SubmitTab delegates to ShareTabParticipantsSelector:
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/pages/Share/SubmitTab.tsx#L8
which mounts MoneyRequestParticipantsSelector unconditionally and only navigates after the user manually taps a destination — it imports neither usePreferredPolicy nor any restriction logic:
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/components/Share/ShareTabParticipantsSelector.tsx#L43-L83
Compare the canonical #76179 fix in ReportUtils.createDraftTransactionAndNavigateToParticipantSelector: when the user is restricted, it resolves the preferred workspace's expense chat, pre-selects it, and navigates straight to confirmation — the picker is never shown:
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/libs/ReportUtils.ts#L11854-L11862
The restriction source of truth is usePreferredPolicy(), which reads the domain security group (enableRestrictedPrimaryPolicy + restrictedPrimaryPolicyID):
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/hooks/usePreferredPolicy.ts#L36-L43
The share Submit flow never consults this. Its only restriction is the option-list row filter:
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/libs/OptionsListUtils/index.ts#L2141
That filter is a filter over isPolicyExpenseChat rows only — it can never skip the picker and it never reorders, so the locked workspace is never pulled to the top ("not even prioritized"). And it silently no-ops whenever isRestrictedToPreferredPolicy evaluates to false at runtime, which is exactly when all workspaces appear. Either way, the "skip straight to confirmation on the locked workspace" behavior is impossible from the share tab, because that decision lives one layer up — in the short-circuit the share tab never calls.
What changes do you think we should make in order to solve the problem?
Give the share Submit flow the same short-circuit the in-product flow got in #76179, scoped to the submit flow (the component already tracks this as isSubmitFlow):
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/components/Share/ShareTabParticipantsSelector.tsx#L29
In ShareTabParticipantsSelector, read usePreferredPolicy() and, when isRestrictedToPreferredPolicy && preferredPolicyID and the locked workspace's expense chat exists, run the same side effects the existing onParticipantsAdded path already runs for a chosen destination — clear the stale draft, start the existing telemetry span, record the selected report ID — and navigate straight to the details route instead of rendering the picker:
const {isRestrictedToPreferredPolicy, preferredPolicyID} = usePreferredPolicy();
const lockedExpenseChat = isSubmitFlow && isRestrictedToPreferredPolicy && preferredPolicyID ? getPolicyExpenseChat(currentUserAccountID, preferredPolicyID) : undefined;
useEffect(() => {
if (!lockedExpenseChat?.reportID) {
return;
}
clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, draftTransactionIDs);
startSpan(CONST.TELEMETRY.SPAN_SHARE_EXTENSION_OPEN_SUBMIT_FLOW, {
/* same attributes as the manual path */
});
setSelectedReportID(lockedExpenseChat.reportID);
Navigation.navigate(detailsPageRouteObject.getRoute(lockedExpenseChat.reportID.toString()));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [lockedExpenseChat?.reportID]);
// avoid flashing the full picker while routing
if (lockedExpenseChat?.reportID) {
return null;
}
Navigating to SHARE_SUBMIT_DETAILS is sufficient — SubmitDetailsPage already inits the money request from the route report and calls setMoneyRequestParticipantsFromReport, so confirmation lands with the locked workspace pre-selected, no extra wiring:
https://github.com/Expensify/App/blob/44f89b024b6605fa42b1cab5b3a6b9eb276765bf/src/pages/Share/SubmitDetailsPage.tsx#L181
Keep it tightly scoped:
- Only short-circuit when
isSubmitFlowandisRestrictedToPreferredPolicy && preferredPolicyID. Non-restricted users, the Share (non-submit) tab, and unknown-user handling keep the current selector unchanged. - Guard against a navigate loop:
clearMoneyRequestwrites to Onyx and re-renders this component, so drive the navigation from an effect keyed on the resolved report ID (fire once). - If the locked policy's expense chat isn't in Onyx yet, fall through to the current picker (which the L2141 filter still narrows) rather than navigating to an empty report.
- Preserve the existing
SPAN_SHARE_EXTENSION_OPEN_SUBMIT_FLOWtelemetry for the auto-selected report, mirroring the manual-selection path soSubmitDetailsPagestill ends the span.
Using usePreferredPolicy() (the exact hook the #76179 fix uses) rather than useDefaultExpensePolicy() keeps the change scoped to the restriction case, so unrestricted single-workspace users aren't silently forced past the picker — a behavior change beyond this bug.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
- Restriction on (
enableRestrictedPrimaryPolicy+restrictedPrimaryPolicyID) with the locked policy's expense chat in Onyx → mount the Submit tab; assert it navigates toSHARE_SUBMIT_DETAILSfor that report and does not renderMoneyRequestParticipantsSelector. - No restriction → the Submit tab still renders the picker and lists the user's workspaces as before.
- Restriction on but the locked policy's expense chat not yet in Onyx → falls back to the picker; no navigation to an empty report.
- Share (non-submit) tab / unknown-user flow → unchanged; the short-circuit never fires.
What alternative solutions did you explore? (Optional)
- Only fixing the option-list filter (
OptionsListUtilsL2141) — rejected. That filter already exists and only trims rows; even when it fires it leaves the user on a single-item picker and never reorders, so it can't restore the skip-to-confirmation behavior the issue asks for, and it no-ops wheneverisRestrictedToPreferredPolicyisfalse. - Using
useDefaultExpensePolicy()instead ofusePreferredPolicy()— it already prioritizes the restricted policy, but it also resolves a default for unrestricted single-policy users, so it would auto-skip the picker for people the domain never restricted — widening the behavior change beyond this bug. The narrowerusePreferredPolicy()gate matches #76179 exactly. - Deciding the destination up in
SubmitTab/ShareRootPageand mountingSubmitDetailsPagedirectly — rejected as over-scoped. The tab set and file-scannability check are owned there; gating tab construction on policy state couples unrelated concerns.ShareTabParticipantsSelectoralready owns the destination route and the selection side effects, so the branch belongs there with a much smaller footprint.
Issue Analysis
Root Cause (medium confidence): The native share‑sheet Submit tab renders the standard participant selector but never applies the "restricted → go straight to the locked workspace" behavior that the quick‑action / long‑tap flow already has. ShareTabParticipantsSelector simply mounts MoneyRequestParticipantsSelector and does not read the domain security group at all, so there is no equivalent of the isRestrictedToPreferredPolicy && preferredPolicyID branch that ReportUtils.createDraftTransactionAndNavigateToParticipantSelector uses (the fix from Expensify/App#76179).
The only restriction the share flow relies on is the option‑list filter in OptionsListUtils.isValidReport:2171, fed by usePreferredPolicy() in ParticipantSearchResults. That filter, at best, narrows the list to one workspace — it does not skip to confirmation. And when it shows all workspaces (the reported symptom), it means usePreferredPolicy() evaluated isRestrictedToPreferredPolicy = false at runtime (security‑group Onyx data missing/incomplete in this entry point), so no filtering applies.
Recommended Fix: In ShareTabParticipantsSelector, for the submit flow (isSubmitFlow), call usePreferredPolicy() and, when isRestrictedToPreferredPolicy && preferredPolicyID and the preferred policy's expense chat exists, bypass the participant selector and navigate straight to the submit details/confirmation page with that workspace pre‑selected — mirroring ReportUtils.ts:11531-11539 (getPolicyExpenseChat(currentUserAccountID, preferredPolicyID) → setMoneyRequestParticipantsFromReport → navigate to the details route). This satisfies both stated expectations: the user only ever sees the locked workspace, and they skip directly to confirmation.
Investigation details & why the existing proposal is off-target
Flow traced: SubmitTab → ShareTabParticipantsSelector → MoneyRequestParticipantsSelector (iouType = SUBMIT) → ParticipantSearchResults → getValidOptions → workspace chats grouped through isValidReport.
- The restriction filter is fully wired end‑to‑end at the current HEAD, so "restriction never passed to options" is not the root cause. The remaining gaps are (a) no auto‑skip in the share tab, and (b) the filter is a no‑op whenever
usePreferredPolicy()returns false. usePreferredPolicy()requiressecurityGroup.enableRestrictedPrimaryPolicy === trueand a non‑emptyrestrictedPrimaryPolicyID, read fromMY_DOMAIN_SECURITY_GROUPS+ theSECURITY_GROUPcollection. If those NVPs aren't populated when the app is entered via the OS share sheet, the restriction silently disappears — worth confirming with a repro/logs.- The quick‑action path (
Expensify/App#76179) already skips to the locked workspace; the share Submit tab was never given the equivalent branch, which matches the "this was previously working / regression" note.
On the existing proposal: it points at useExpenseSubmission.ts (senderWorkspaceID / existingInvoiceReport). That code is invoice sender‑workspace logic and is not on the share‑sheet Submit path — it does not address this bug.
Verification suggested before implementing: reproduce with a domain group that has enableRestrictedPrimaryPolicy set, and log usePreferredPolicy() inside the share flow to confirm whether it returns true there. That tells you whether the fix is purely the auto‑skip (hook returns true) or also needs the security‑group data loaded for the share entry point (hook returns false).
Related issues: Expensify/App#76179 (closed) — same root cause (domain‑controlled workspace restriction not applied to a quick‑create flow); its fix lives in ReportUtils.createDraftTransactionAndNavigateToParticipantSelector and is the pattern to mirror here.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/95672) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 10:17:13 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue
When a user belongs to a domain with a security group that restricts expense submission to one specific workspace, that restriction is correctly enforced inside the app (quick-action, long-tap, in-product submit flow). But when they use the native iOS or Android share sheet to attach a receipt, the Submit tab shows every workspace they belong to with no filtering. They can attempt to submit to a workspace their admin has explicitly locked them out of, and the correct restricted workspace isn't even surfaced first.
This is a regression from a fix that previously worked (closed #76179 fixed the same root cause for the long-tap quick-action path).
What is the root cause of that problem?
The fix from #76179 lives in ReportUtils.createDraftTransactionAndNavigateToParticipantSelector. When isRestrictedToPreferredPolicy && preferredPolicyID is true, it short-circuits the participant selector entirely — it looks up the preferred policy's expense chat, pre-selects it via setMoneyRequestParticipantsFromReport, then navigates straight to the confirmation step. The user never sees the workspace list.
// ReportUtils.ts — createDraftTransactionAndNavigateToParticipantSelector
if (isRestrictedToPreferredPolicy && preferredPolicyID) {
const policyExpenseReport = getPolicyExpenseChat(deprecatedCurrentUserAccountID, preferredPolicyID);
if (policyExpenseReport) {
setMoneyRequestParticipantsFromReport(transactionID, policyExpenseReport, deprecatedCurrentUserAccountID).then(() => {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
CONST.IOU.ACTION.SUBMIT,
CONST.IOU.TYPE.SUBMIT,
transactionID,
policyExpenseReport.reportID,
),
);
});
return; // ← exits before participant selector is shown
}
}
The share sheet submit flow never calls createDraftTransactionAndNavigateToParticipantSelector. Instead, ShareTabParticipantsSelector mounts MoneyRequestParticipantsSelector directly, skipping all of that logic. It never reads the domain security group via usePreferredPolicy(), so isRestrictedToPreferredPolicy is never evaluated, and the workspace list is always shown in full.
The secondary defense — OptionsListUtils.isValidReport fed by usePreferredPolicy() inside ParticipantSearchResults — can narrow the list when it works, but it fails for the share sheet entry point because isRestrictedToPreferredPolicy evaluates to false (the Onyx security group data isn't loaded or the hook is never called in this context). And even when it works, narrowing the list is the wrong behavior: the user should be sent directly to confirmation, not shown a single-entry selector.
In short: ShareTabParticipantsSelector has a missing branch that every other submit-flow entry point has had since #76179.
What changes do you think we should make in order to solve the problem?
The fix is to add the same isRestrictedToPreferredPolicy branch inside ShareTabParticipantsSelector (or whichever component orchestrates the share sheet submit flow before the participant selector mounts).
Step 1 — call usePreferredPolicy at the share sheet entry point
usePreferredPolicy is the hook that reads the domain security group Onyx data and computes isRestrictedToPreferredPolicy and preferredPolicyID. It must be called in ShareTabParticipantsSelector (or its parent screen) for the submit flow, the same way it's used in createDraftTransactionAndNavigateToParticipantSelector.
// ShareTabParticipantsSelector.tsx (approximate — actual file path may vary)
import usePreferredPolicy from '@hooks/usePreferredPolicy';
import {getPolicyExpenseChat, setMoneyRequestParticipantsFromReport} from '@userActions/IOU';
function ShareTabParticipantsSelector({transactionID, iouType, ...}) {
const {isRestrictedToPreferredPolicy, preferredPolicyID} = usePreferredPolicy();
const currentUserAccountID = useCurrentUserAccountID();
// Mirror the restriction bypass from ReportUtils.createDraftTransactionAndNavigateToParticipantSelector
useEffect(() => {
if (!isSubmitFlow) return;
if (!isRestrictedToPreferredPolicy || !preferredPolicyID) return;
const policyExpenseReport = getPolicyExpenseChat(currentUserAccountID, preferredPolicyID);
if (!policyExpenseReport?.reportID) return;
// Pre-select the locked workspace and jump straight to confirmation.
// User should never see the participant selector when their domain
// security group has already made the decision for them.
setMoneyRequestParticipantsFromReport(transactionID, policyExpenseReport, currentUserAccountID).then(() => {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
CONST.IOU.ACTION.SUBMIT,
CONST.IOU.TYPE.SUBMIT,
transactionID,
policyExpenseReport.reportID,
),
);
});
}, [isRestrictedToPreferredPolicy, preferredPolicyID, transactionID, currentUserAccountID, isSubmitFlow]);
// If restricted and we have a preferred policy, the effect above will navigate away.
// Show nothing (or a loading state) until that navigation fires.
if (isSubmitFlow && isRestrictedToPreferredPolicy && preferredPolicyID) {
return null;
}
// Normal path — no restriction, show full participant selector
return <MoneyRequestParticipantsSelector ... />;
}
Why useEffect instead of a useMemo early return:
The bypass requires an async operation (setMoneyRequestParticipantsFromReport returns a promise). Triggering it in a useEffect that runs on mount (before the participant selector has rendered) matches the existing pattern and avoids showing the unfiltered list even momentarily.
Step 2 — verify usePreferredPolicy reads security group Onyx data correctly in this context
The existing failure mode is that isRestrictedToPreferredPolicy evaluates to false in the share sheet flow even when it should be true. Before the PR, verify that usePreferredPolicy reads from Onyx correctly when entered from the share sheet entry point. If the security group data isn't loaded yet, a useOnyx subscription inside usePreferredPolicy should handle it automatically — but confirm this is the case. If it isn't, the Onyx key subscription needs to be added to whatever bootstrapping the share sheet flow does.
Step 3 — find the exact file path
The issue mentions ShareTabParticipantsSelector but the actual file may be:
src/pages/iou/ShareDetailsPage.tsx
src/pages/iou/request/ShareTabParticipantsSelector.tsx
src/pages/ShareRootPage.tsx
Grep for it:
grep -rn "ShareTab\|shareSheet\|MoneyRequestParticipantsSelector" \
src/pages/iou/ src/pages/Share* | grep -v node_modules
The component that mounts MoneyRequestParticipantsSelector for the share-sheet submit path is the one to patch.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
// tests/unit/ShareTabParticipantsSelectorTest.tsx
describe('ShareTabParticipantsSelector — domain security group restriction', () => {
it('bypasses participant selector and navigates to confirmation when user is restricted to preferred policy', async () => {
// Arrange: user belongs to domain with security group restricting to policyA
await Onyx.merge(ONYXKEYS.PREFERRED_POLICY, {
isRestrictedToPreferredPolicy: true,
preferredPolicyID: 'policyA',
});
// policyA has a policy expense chat
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}expenseChatForPolicyA`, {
reportID: 'expenseChatForPolicyA',
policyID: 'policyA',
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
isOwnPolicyExpenseChat: true,
ownerAccountID: currentUserAccountID,
});
const navigationSpy = jest.spyOn(Navigation, 'navigate');
render(<ShareTabParticipantsSelector transactionID="txn_1" iouType={CONST.IOU.TYPE.SUBMIT} isSubmitFlow />);
// Should navigate to confirmation without showing participant list
await waitFor(() => {
expect(navigationSpy).toHaveBeenCalledWith(
expect.stringContaining(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
CONST.IOU.ACTION.SUBMIT,
CONST.IOU.TYPE.SUBMIT,
'txn_1',
'expenseChatForPolicyA',
)),
);
});
// The full workspace list should never have rendered
expect(screen.queryByTestId('participant-selector-list')).toBeNull();
});
it('shows full participant selector when user is not restricted', async () => {
await Onyx.merge(ONYXKEYS.PREFERRED_POLICY, {
isRestrictedToPreferredPolicy: false,
preferredPolicyID: undefined,
});
render(<ShareTabParticipantsSelector transactionID="txn_2" iouType={CONST.IOU.TYPE.SUBMIT} isSubmitFlow />);
await waitFor(() => {
expect(screen.getByTestId('participant-selector-list')).toBeTruthy();
});
});
it('shows full selector when restricted but preferred policy has no expense chat yet', async () => {
// Edge: restriction flag is set but the policy expense chat hasn't been created
await Onyx.merge(ONYXKEYS.PREFERRED_POLICY, {
isRestrictedToPreferredPolicy: true,
preferredPolicyID: 'policyB',
});
// No expense chat for policyB in Onyx
render(<ShareTabParticipantsSelector transactionID="txn_3" iouType={CONST.IOU.TYPE.SUBMIT} isSubmitFlow />);
// Should fall through to the normal selector rather than hanging on null
await waitFor(() => {
expect(screen.getByTestId('participant-selector-list')).toBeTruthy();
});
});
it('does not apply restriction bypass for non-submit flows (e.g. track, split)', async () => {
await Onyx.merge(ONYXKEYS.PREFERRED_POLICY, {
isRestrictedToPreferredPolicy: true,
preferredPolicyID: 'policyA',
});
const navigationSpy = jest.spyOn(Navigation, 'navigate');
render(<ShareTabParticipantsSelector transactionID="txn_4" iouType={CONST.IOU.TYPE.TRACK} isSubmitFlow={false} />);
// Restriction only applies to submit flow — track/split should show normal selector
await waitFor(() => {
expect(screen.getByTestId('participant-selector-list')).toBeTruthy();
});
expect(navigationSpy).not.toHaveBeenCalled();
});
});
What alternative solutions did you explore?
Relying solely on OptionsListUtils.isValidReport filtering inside ParticipantSearchResults — when usePreferredPolicy() returns isRestrictedToPreferredPolicy: true, the option list filtering can hide other workspaces and show only the preferred one. The problems: (a) the reported symptom is that isRestrictedToPreferredPolicy evaluates to false in the share sheet context, so the filter doesn't fire; (b) even when it works, showing a single-entry list is the wrong UX — the user should go straight to confirmation with no extra tap; (c) this is exactly the UX pattern that was rejected for the #76179 fix in favor of the bypass approach.
Moving the restriction check into MoneyRequestParticipantsSelector itself — making the common component aware of the security group restriction so every caller gets the behavior automatically. This is cleaner architecturally but is a larger surface area change that risks breaking callers that have different needs. The targeted fix in ShareTabParticipantsSelector is lower risk and exactly mirrors what every other entry point already does explicitly.
Files expected to change
src/pages/iou/request/ShareTabParticipantsSelector.tsx — add usePreferredPolicy bypass
(or whichever component mounts MoneyRequestParticipantsSelector for the share sheet submit path)
tests/unit/ShareTabParticipantsSelectorTest.tsx — 4 new test cases above
Proposal
What is the root cause of that problem?
The share sheet Submit tab renders the generic money-request participant selector, and the restriction that domain security groups enforce is only ever applied to one slice of that list — the workspace-chat rows — while every other destination type is left wide open.
ShareTabParticipantsSelector mounts MoneyRequestParticipantsSelector with iouType={SUBMIT} / action="create" and no scoping flags:
https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/components/Share/ShareTabParticipantsSelector.tsx#L42-L85
Because action is create (not share/categorize), ParticipantSearchResults turns on P2P recipients, recent chats, and invite-by-email for this list:
https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/pages/iou/request/ParticipantSearchResults.tsx#L186-L204
The only domain-restriction that runs is the workspace-chat filter in getValidOptions, which drops policy-expense chats whose policyID isn't the preferred one:
https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/libs/OptionsListUtils/index.ts#L2171
That filter touches isPolicyExpenseChat rows only. The recents/contacts/invite sections are gated purely on !isWorkspacesOnly, so they render regardless of any security group:
https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/pages/iou/request/ParticipantSearchResults.tsx#L326-L344
So a domain-restricted user in the share Submit tab is still handed recents, contacts, and invite-by-email as submission targets, and the one workspace they're actually allowed to use is buried in the list with no priority — matching the issue's "not even prioritized at the top" complaint. Neither isWorkspacesOnly nor shouldExcludeP2P is ever set for the submit flow, and the preferred workspace's expense chat is never fed in as a pre-selection.
What changes do you think we should make in order to solve the problem?
Scope the share Submit selector to workspaces only and pre-lock the allowed workspace, instead of leaving the general people-picker in place. All of this is done by passing existing props MoneyRequestParticipantsSelector already supports — no new selector behavior is invented:
https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx#L31-L51
In ShareTabParticipantsSelector, for the submit flow (detailsPageRouteObject === ROUTES.SHARE_SUBMIT_DETAILS):
- Pass
isWorkspacesOnlyandshouldExcludeP2P. This removes recents, contacts, and invite-by-email from the Submit tab so the receipt can only be routed to a workspace — closing the "submit anywhere" hole that the current workspace-only filter leaves open. - Read the domain restriction with
usePreferredPolicy()/useDefaultExpensePolicy(). When restricted (or when there's a single accessible group policy), resolvegetPolicyExpenseChat(currentUserAccountID, preferredPolicyID)and pass itsreportIDasinitiallySelectedReportIDtogether withshouldMoveSelectedToTop, so the allowed workspace is pinned to the top and pre-selected.
https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/hooks/useDefaultExpensePolicy.tsx#L51-L59 https://github.com/Expensify/App/blob/7f298345fda5839378464d1caed616b3ef143b0d/src/libs/ReportUtils.ts#L9762
Combined with the existing preferred-policy filter, the restricted user now sees exactly one destination — their locked workspace — already selected at the top, and cannot pick a person or another workspace. Unrestricted users keep a normal (now workspace-scoped) Submit list. A regression test can mount the Submit tab with a restricted security group and assert the list contains only the preferred workspace chat and that it is pre-selected.
What alternative solutions did you explore? (Optional)
Skip the picker entirely and auto-navigate to SHARE_SUBMIT_DETAILS with the locked expense chat, mirroring the in-product global-create short-circuit. That restores the exact "jump straight to confirmation" behavior but replaces the whole Submit-tab UI with an implicit redirect, which is a heavier behavioral change and offers no recovery path when the preferred workspace's expense chat can't be resolved; keeping a one-item, pre-selected workspace-only picker degrades more gracefully in that case while still honoring the restriction.
⚠️ @lorretheboy Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 10:09:33 UTC.
Proposal
What is the root cause of that problem?
The native share Submit tab enters the App share flow, but SubmitTab delegates straight to ShareTabParticipantsSelector, and that component always renders the generic money-request participant picker before it knows whether the user is locked to a domain-preferred workspace.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/pages/Share/SubmitTab.tsx#L7-L8
ShareTabParticipantsSelector passes iouType={CONST.IOU.TYPE.SUBMIT} to MoneyRequestParticipantsSelector and only navigates to the submit details route after onParticipantsAdded runs. There is no submit-only branch that resolves the restricted policy expense chat and skips the picker.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/components/Share/ShareTabParticipantsSelector.tsx#L42-L85
The restriction source of truth already exists elsewhere. usePreferredPolicy() derives the domain security group's isRestrictedToPreferredPolicy / preferredPolicyID, and useDefaultExpensePolicy() returns that accessible preferred group policy before falling back to the active or single group policy.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/hooks/usePreferredPolicy.ts#L21-L45 https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/hooks/useDefaultExpensePolicy.tsx#L36-L53
The in-product global-create scan flow consumes that default-policy path before opening a participant picker: it uses shouldUseDefaultExpensePolicy(), resolves the policy expense chat, sets it on the transaction, and navigates to confirmation; otherwise it falls back to the participant picker. The share Submit entry point bypasses that shortcut, so a restricted user can see the destination picker/workspace list instead of being routed to the locked workspace confirmation.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/pages/iou/request/step/IOURequestStepScan/components/NavigateGlobalCreateContext.tsx#L95-L130
The existing preferred-policy filter in the picker is only a fallback row filter. It can remove non-preferred policy expense chats after the picker is rendered, but it cannot restore the expected skip-to-confirmation behavior.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/pages/iou/request/ParticipantSearchResults.tsx#L179-L204 https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/libs/OptionsListUtils/index.ts#L2167-L2173
What changes do you think we should make in order to solve the problem?
In ShareTabParticipantsSelector, add a submit-only auto-destination path before rendering MoneyRequestParticipantsSelector.
When detailsPageRouteObject === ROUTES.SHARE_SUBMIT_DETAILS, read isRestrictedToPreferredPolicy from usePreferredPolicy(), resolve defaultExpensePolicy through useDefaultExpensePolicy(), and reuse the same billing/default-policy guard used by global-create scan. Call shouldUseDefaultExpensePolicy() with CONST.IOU.TYPE.CREATE, not CONST.IOU.TYPE.SUBMIT, because the helper only returns true for create-flow defaulting and the share Submit receipt flow is functionally creating a new expense from a receipt.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/libs/shouldUseDefaultExpensePolicy.ts#L18-L23
If the user is restricted to a preferred policy and the create-flow guard passes, resolve the locked workspace's expense chat with getPolicyExpenseChat(currentUserAccountID, defaultExpensePolicy?.id). When that report exists, clear the stale optimistic money request draft just like the manual selection path does, set/update the existing share-submit telemetry report ID, store the selected report ID, and navigate to detailsPageRouteObject.getRoute(policyExpenseChat.reportID). Render null or the existing loading state while this effect routes so the picker does not flash.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/libs/ReportUtils.ts#L9762-L9774
This route is enough for the existing details page: SubmitDetailsPage initializes the scan money request from the route report and then calls setMoneyRequestParticipantsFromReport() so the confirmation screen has the locked workspace selected.
https://github.com/Expensify/App/blob/daeafbc4cb510692ece1c2488a42bc49d2728428/src/pages/Share/SubmitDetailsPage.tsx#L159-L175
If the restricted policy expense chat is not available yet, keep the current picker as the fallback and rely on the existing preferred-policy option filter so only the allowed workspace can be selected. Keep the change scoped to ROUTES.SHARE_SUBMIT_DETAILS; the regular Share tab, unknown-user handling, and unrestricted users should continue through the current selector path.
Test coverage:
- Add a unit/component test for
ShareTabParticipantsSelectorwithenableRestrictedPrimaryPolicy,restrictedPrimaryPolicyID, a matching accessible policy, and a matching policy expense chat; assert the Submit route variant navigates directly toSHARE_SUBMIT_DETAILSfor that report and does not renderMoneyRequestParticipantsSelector. - Add a negative test with no restriction or no qualifying default policy; assert the selector still renders.
- Add a fallback test where the restriction exists but the policy expense chat is not in Onyx yet; assert the selector renders and the existing preferred-policy filter prevents selecting non-preferred workspace chats.
What alternative solutions did you explore? (Optional)
I considered fixing only OptionsListUtils.isValidReport() / useSearchSelector() so the picker lists just the preferred workspace. That is still useful fallback protection, but it leaves restricted users on a picker and does not restore the previously working skip-to-confirmation behavior.
I also considered using preferredPolicyID directly without the default-policy guard. That is narrower, but it would bypass the same billing/default-policy checks the global-create scan flow already uses, and it misses the important detail that shouldUseDefaultExpensePolicy() must be evaluated as a create-flow receipt action rather than as SUBMIT.
Finally, I considered moving the shortcut into ShareRootPage or SubmitTab. That would couple tab construction and file-scannability to destination policy resolution. ShareTabParticipantsSelector is the smaller ownership point because it already owns the submit-vs-share destination route and the manual participant selection side effects.
| Before | After |
|---|---|
⚠️ @KJ21-ENG Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Proposal Updated
Reworked the root cause. My earlier version blamed the share extension for not loading the security-group Onyx keys, but that is not what happens - on iOS the extension just saves the file and reopens the main app at new-expensify://share/root, so the Submit tab runs in the normal app with the full store already loaded.
The real gap is that the share Submit flow never applies the domain-controlled workspace short-circuit that the in-product create flow got in #76477, so a locked user lands on the picker instead of going straight to confirmation. Updated the fix to reuse useDefaultExpensePolicy in ShareTabParticipantsSelector.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user belongs to a private domain whose security group restricts submission to a single preferred workspace, opening a receipt through the native iOS/Android share sheet and going to the Submit tab drops them on the generic destination picker, instead of taking them straight to the confirmation screen for the one workspace their security group allows. The reporter also notes that the restricted workspace is not given any priority in that list.
What is the root cause of that problem?
The domain security group's "restricted primary policy" setting is exposed to the app through the usePreferredPolicy hook, which returns isRestrictedToPreferredPolicy and preferredPolicyID:
https://github.com/Expensify/App/blob/7b907c2a40bd5a03b5e37667fff424dee3fb5e53/src/hooks/usePreferredPolicy.ts#L21-L46
Every other entry point into the submit flow consults that hook and short-circuits the participant step when the restriction is on. The canonical example is createDraftTransactionAndNavigateToParticipantSelector in ReportUtils: when the user is restricted, it resolves the preferred workspace's expense chat with getPolicyExpenseChat, sets it as the participant, and navigates directly to the confirmation step — never showing the picker:
https://github.com/Expensify/App/blob/7b907c2a40bd5a03b5e37667fff424dee3fb5e53/src/libs/ReportUtils.ts#L11521-L11532
The same pattern is repeated in the quick-action menu item, the composer attachment picker, the composer drop zone, and the chat actionable buttons — all of which consult usePreferredPolicy before deciding what the submit flow should do.
The share sheet's Submit tab is the one submit entry point that never does this. SubmitTab renders ShareTabParticipantsSelector unconditionally:
https://github.com/Expensify/App/blob/7b907c2a40bd5a03b5e37667fff424dee3fb5e53/src/pages/Share/SubmitTab.tsx#L7-L9
and ShareTabParticipantsSelector mounts MoneyRequestParticipantsSelector immediately, with no reference to usePreferredPolicy anywhere in the component:
https://github.com/Expensify/App/blob/7b907c2a40bd5a03b5e37667fff424dee3fb5e53/src/components/Share/ShareTabParticipantsSelector.tsx#L24-L45
So for the share flow there is no restricted-workspace short-circuit at all: the user is always dropped onto the generic destination picker.
To be precise about what the picker does and does not already honour: the selector's own option list is restriction-aware. ParticipantSearchResults, which MoneyRequestParticipantsSelector renders, calls usePreferredPolicy itself and forwards isRestrictedToPreferredPolicy and preferredPolicyID into the options config, and getValidOptions then drops every policy expense chat that does not belong to the preferred policy:
https://github.com/Expensify/App/blob/7b907c2a40bd5a03b5e37667fff424dee3fb5e53/src/libs/OptionsListUtils/index.ts#L2165-L2171
That filter is the only place preferredPolicyID is consulted in the options pipeline — it is a filter over policy expense chats, never an ordering rule. So two things follow. The workspace rows are already narrowed to the permitted workspace, but self-DM and personal contacts are unaffected by the restriction and still render, so the screen still presents itself as a general destination picker rather than the locked confirmation screen the user expects. And because nothing above the selector short-circuits, the restricted user is forced through a destination step that every other submit entry point skips outright.
That is why the behaviour differs from the in-product submit flows, and why it reads as a regression relative to the previously-working "skip straight to confirmation with the locked workspace" behaviour. It is the same class of gap as the previously-closed issue where the domain-controlled workspace restriction was not applied to the quick-action flow.
What changes do you think we should make in order to solve the problem?
Make the share sheet's Submit tab honour the domain security group restriction the same way the rest of the submit flow already does.
In ShareTabParticipantsSelector, read isRestrictedToPreferredPolicy and preferredPolicyID from usePreferredPolicy. When the restriction is active and a preferred policy ID is present, resolve that workspace's expense chat with the existing getPolicyExpenseChat helper using the current user's account ID — the exact call createDraftTransactionAndNavigateToParticipantSelector already makes for this case.
If that expense chat resolves, skip rendering the participant selector entirely. Instead, run the same side effects the component's onParticipantsAdded callback performs for a chosen destination — clear the stale draft transaction, record the selected report ID, start the submit-flow telemetry span — and navigate straight to the details/confirmation route for that report using the component's detailsPageRouteObject. Two details matter here. The navigation belongs in an effect rather than in render, and it must be fired only once: clearing the draft transaction writes to Onyx, which re-renders the component, so an unguarded effect would navigate repeatedly. And getPolicyExpenseChat searches the reports collection, so the resolution has to be driven by a subscription to that collection rather than a one-shot read taken at mount, otherwise a user whose reports have not finished loading would be sent to the picker and never re-evaluated.
While that collection is still loading, render a loading indicator in place of the selector rather than flashing the picker, so the user never sees a destination list they are not permitted to choose from. The component has no loading state today — it mounts the selector unconditionally — so this is a new branch, not a reuse of an existing skeleton.
If the restriction is on but the preferred workspace's expense chat still cannot be resolved once reports have loaded, fall back to rendering the selector as it does today. That keeps the flow usable rather than dead-ending, and as described above the selector already filters policy expense chat options against preferredPolicyID, so the fallback list stays consistent with the restriction.
This keeps the fix contained to the share flow's own component, reuses the helper and navigation pattern already established for every other restricted submit entry point, and restores the intended behaviour of landing on the confirmation screen with the locked workspace pre-selected.
A regression test should assert that, with a security group that has enableRestrictedPrimaryPolicy enabled and a restrictedPrimaryPolicyID set, mounting the share Submit tab navigates to the submit details route for the preferred workspace's expense chat and does not render the participant selector — and that with the restriction disabled the selector still renders as before.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/95672-share-submit-preferred-policy?expand=1
What alternative solutions did you explore? (Optional)
I considered leaving the picker in place and relying only on the option filter to narrow the list to the single permitted workspace. I rejected this because it is essentially the current behaviour: that filter already exists in getValidOptions, and it is what the share Submit tab renders today. It does not match the behaviour described in the issue as previously working, it still forces the user through a selection screen on every share — an extra tap the in-product flows deliberately avoid — and because the filter only narrows policy expense chats, self-DM and personal contacts remain in the list, so the destination screen still does not read as locked to one workspace.
I also considered pushing the short-circuit up into ShareRootPage, so the Submit tab would never mount when the user is restricted. I rejected this because the tab navigator's tab set and the file-scannability check are owned there, and gating tab construction on policy state would couple unrelated concerns; the selector component is where the destination decision genuinely belongs, and it is also where the equivalent logic lives for the other submit entry points.
⚠️ @wildan-m Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user whose domain security group restricts submission to a single workspace shares a receipt via the native iOS/Android share sheet and opens the Submit tab, they are dropped on the workspace picker instead of being taken straight to the confirmation screen with the locked workspace already selected — unlike the in‑product "scan a receipt" flow, which auto‑selects that workspace and skips the picker.
What is the root cause of that problem?
The share‑sheet Submit tab does not reuse the "default/restricted expense policy → skip the picker → go straight to confirmation" logic that the rest of the app uses. It renders the generic participant picker unconditionally.
SubmitTabjust rendersShareTabParticipantsSelectorwith the submit route:SubmitTab.tsx#L7-L9.ShareTabParticipantsSelectoralways rendersMoneyRequestParticipantsSelector(the picker) and only navigates to the confirmation/details screen after the user manually taps a workspace — it never checks whether the user has a locked/default workspace first:ShareTabParticipantsSelector.tsx#L42-L86. The manual‑selection branch that navigates toSHARE_SUBMIT_DETAILSis here:ShareTabParticipantsSelector.tsx#L79-L82.
Compare with the in‑product global‑create scan flow, which is the "matching experience" the issue refers to. Before showing a picker, it asks shouldUseDefaultExpensePolicy(...); when true it resolves the default workspace's expense chat and navigates straight to confirmation, only falling back to the picker otherwise: NavigateGlobalCreateContext.tsx#L95-L131 (guard at #L97, confirmation navigation at #L125, picker fallback navigateToParticipantPage at #L129).
For a domain‑restricted user this default policy is the locked workspace: useDefaultExpensePolicy returns the preferred policy whenever usePreferredPolicy().isRestrictedToPreferredPolicy is set: useDefaultExpensePolicy.tsx#L51-L52, and usePreferredPolicy derives that from the domain security group (enableRestrictedPrimaryPolicy + restrictedPrimaryPolicyID): usePreferredPolicy.ts#L21-L44. Because the share Submit tab never consults these, the restricted user always lands on the picker instead of skipping to confirmation.
Note — the picker's workspace list is already gated by the domain restriction: ParticipantSearchResults passes isRestrictedToPreferredPolicy/preferredPolicyID into the options builder (ParticipantSearchResults.tsx#L179, #L202-L203), and isValidReport drops every non‑preferred workspace chat: OptionsListUtils/index.ts#L2171. So the missing piece is not list filtering — it's the skip to confirmation. The correct behavior is to not show the Submit‑tab picker at all for these users, exactly as the in‑product flow does.
What changes do you think we should make in order to solve the problem?
Give the share Submit tab the same "skip to confirmation with the default/locked workspace" behavior the in‑product scan flow already has.
In ShareTabParticipantsSelector, for the submit flow only (detailsPageRouteObject === ROUTES.SHARE_SUBMIT_DETAILS, which the component already tracks as isSubmitFlow), add a mount effect that:
- Reads
const defaultExpensePolicy = useDefaultExpensePolicy();(plus the billing‑grace/amountOwedvalues the guard needs). - If
shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, defaultExpensePolicy, amountOwed, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, currentUserAccountID)is true, resolves the target workspace chat withgetPolicyExpenseChat(currentUserAccountID, defaultExpensePolicy.id)and auto‑selects it — reusing the exact navigation the manual selection already performs (Navigation.navigate(detailsPageRouteObject.getRoute(targetReport.reportID)),#L79-L82). - Otherwise renders the picker as it does today.
This is intentionally minimal: it reuses the already‑shipped shouldUseDefaultExpensePolicy + useDefaultExpensePolicy resolution and the component's own navigation path, mirroring NavigateGlobalCreateContext (#L97-L129) rather than inventing new restriction logic.
Note on the iouType: the share Submit tab passes iouType={CONST.IOU.TYPE.SUBMIT} (#L44), but shouldUseDefaultExpensePolicy gates on iouType === CONST.IOU.TYPE.CREATE (shouldUseDefaultExpensePolicy.ts#L19). Sharing a receipt is functionally a global‑create‑from‑receipt (the same thing the scan flow does), so we should pass CONST.IOU.TYPE.CREATE to that guard — passing SUBMIT would make it always return false and the skip would silently never fire.
Because the fire condition is identical to the in‑product flow, users with no single default/locked workspace (multiple workspaces, no restriction) still see the picker — the skip only triggers for the restricted / single‑default‑policy case, matching the in‑product experience and avoiding an unwanted auto‑skip.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
- Restricted domain user — security group with
enableRestrictedPrimaryPolicy: trueandrestrictedPrimaryPolicyIDpointing to an accessible group workspace: rendering the Submit tab navigates straight toSHARE_SUBMIT_DETAILSfor that workspace's expense chat and does not render the participant picker. - Single default group policy, no restriction — same auto‑skip to confirmation.
- Negative case — user with multiple workspaces / no qualifying default policy: the participant picker is still shown (no auto‑skip).
- Unit coverage for the guard wiring:
useDefaultExpensePolicyreturns the preferred policy whenisRestrictedToPreferredPolicyis set, andshouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, …)returnstrue/falsefor the three cases above.
What alternative solutions did you explore? (Optional)
- List‑filter only (rejected): rely on the existing
usePreferredPolicyfiltering in the picker (OptionsListUtils/index.ts#L2171) and optionally auto‑select when exactly one workspace remains. This is already in place and still leaves the user on a picker, so it does not deliver the "skip directly to confirmation" behavior the issue asks for, and it wouldn't cover the single‑default‑policy (non‑restricted) case. - Decide the destination before rendering the tabs (rejected as over‑scoped): compute the target workspace in
ShareRootPage/SubmitTaband mountSubmitDetailsPagedirectly instead of the picker. Same end result but more invasive to the tab navigator; the targeted effect inShareTabParticipantsSelectorreuses the existing navigation with a much smaller footprint. - Reuse
useDefaultParticipants(rejected): it short‑circuits unless the transaction is flagged as a global‑create/FAB flow, which the share flow isn't — soshouldUseDefaultExpensePolicy(passingCONST.IOU.TYPE.CREATE) is the smaller, more direct lever here.
Updated my proposal.
What changed: Clarified that the share Submit shortcut should reuse the create-flow default-policy guard, clear stale draft state, and keep the picker filter as fallback.
Why: This preserves billing/default-policy behavior while restoring locked-workspace confirmation instead of relying on picker filtering alone.
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
⚠️ @trasnake87 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.