Skip to content

[Due for payment 2026-04-16] [$250] Default share sheet option to Submit vs Share for all members #81503

Closed

Description

@JmillsExpensify

We're currently defaulting the mobile share sheet to Share vs Submit for some reason – even though our mainline case is Submit. As a result, let's fix that and make sure that the initial option is always Submit, especially since you can submit to yourself if you aren't a member of a paid workspace.

Image
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022019352367484056211
  • Upwork Job ID: 2019352367484056211
  • Last Price Increase: 2026-02-05
Issue OwnerCurrent Issue Owner: @daledah

Activity

  1. added
    External
    Daily
    on Feb 5, 2026
  2. added
    Bug
    on Feb 5, 2026
  3. changed the title [-]Default share sheet option to `Submit` vs `Share` for all members[/-] [+][$250] Default share sheet option to `Submit` vs `Share` for all members[/+] on Feb 5, 2026
  4. melvin-bot commented on Feb 5, 2026

    @melvin-bot
  5. added
    Help Wanted
    on Feb 5, 2026
  6. melvin-bot commented on Feb 5, 2026

    @melvin-bot

    Current assignee @JmillsExpensify is eligible for the Bug assigner, not assigning anyone new.

  7. melvin-bot commented on Feb 5, 2026

    @melvin-bot

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

  8. daledah commented on Feb 5, 2026

    @daledah
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-09 20:23:08 UTC.

    Proposal

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

    Actual Result:
    We're currently defaulting the mobile share sheet to Share vs Submit for some reason – even though our mainline case is Submit. As a result, let's fix that and make sure that the initial option is always Submit, especially since you can submit to yourself if you aren't a member of a paid workspace.

    What is the root cause of that problem?

    In ShareRootPage.tsx, the ShareTab is defined before the SubmitTab inside the OnyxTabNavigator:

    <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>
    {isFileScannable && <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>{() => <SubmitTab ref={submitTabInputRef} />}</TopTab.Screen>}

    Since the OnyxTabNavigator uses the first tab as the default when no defaultSelectedTab is specified, the Share tab becomes the default instead of Submit.

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

    Swap the order of the tabs in ShareRootPage.tsx so that SubmitTab comes first when the file is scannable:

    - <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>
    - {isFileScannable && <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>{() => <SubmitTab ref={submitTabInputRef} />}</TopTab.Screen>}
    + {isFileScannable && <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>{() => <SubmitTab ref={submitTabInputRef} />}</TopTab.Screen>}
    + <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>

    What alternative solutions did you explore? (Optional)

    We could pass defaultSelectedTab={CONST.TAB.SHARE.SUBMIT} to the OnyxTabNavigator (or only pass defaultSelectedTab when isFileScannable is true)

  9. twinkle-react commented on Feb 5, 2026

    @twinkle-react

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-05 11:30:45 UTC.

    Proposal

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

    When opening the mobile share sheet with a scannable attachment, the initial tab selected on mount is Share instead of Submit. For scannable attachments, the initial tab on mount must be Submit.

    What is the root cause of that problem?

    In this flow, ShareRootPage assumes that the default tab passed to the navigator or the tab order is enough to control the initial tab on mount, but this is wrong because OnyxTabNavigator restores a previously persisted selected tab from Onyx if it exists. This behavior is implemented in OnyxTabNavigator.tsx inside the logic that resolves validInitialTab, which allows a persisted value to override the desired initial tab, causing the wrong tab to be selected when the navigator mounts.

    // OnyxTabNavigator.tsx
    const [selectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${id}`, {canBeMissing: true});
    const tabNames = useMemo(() => getTabNames(children), [children]);
    const validInitialTab = selectedTab && tabNames.includes(selectedTab) ? selectedTab : defaultSelectedTab;

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

    The share flow must enforce the correct initial tab before the tab navigator mounts. This is done by writing the desired tab selection to persisted state as soon as a scannable file is detected, and by also passing a defensive defaultSelectedTab to the navigator.

    Add the import near the top of the file.

    // src/pages/Share/ShareRootPage.tsx
    import Tab from '@userActions/Tab';

    Update the logic where the temporary file is processed. The persisted tab is set synchronously before allowing the navigator to mount.

    // src/pages/Share/ShareRootPage.tsx
    if (tempFile) {
        if (tempFile.mimeType) {
            if (receiptFileFormats.includes(tempFile.mimeType) && fileExtension) {
                setIsFileScannable(true);
                // Enforce initial tab selection on mount for scannable attachments.
                // Minimal, deterministic write so persisted state won't override the initial selection.
                Tab.setSelectedTab(CONST.TAB.SHARE.NAVIGATOR_ID, CONST.TAB.SHARE.SUBMIT);
            } else {
                setIsFileScannable(false);
            }
            validateFileIfNecessary(tempFile);
            // Now allow the navigator to mount (after the deterministic write above).
            setIsFileReady(true);
        }
        addTempShareFile(tempFile);
    }

    Define a defensive default tab and pass it into the navigator.

    // src/pages/Share/ShareRootPage.tsx
    const defaultSelectedTab = isFileScannable ? CONST.TAB.SHARE.SUBMIT : CONST.TAB.SHARE.SHARE;
    
    <OnyxTabNavigator
        id={CONST.TAB.SHARE.NAVIGATOR_ID}
        defaultSelectedTab={defaultSelectedTab}
        tabBar={TabSelector}
        lazyLoadEnabled
        onTabSelect={onTabSelectFocusHandler}
    >
        <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>
            {() => <ShareTab ref={shareTabInputRef} />}
        </TopTab.Screen>
        {isFileScannable && (
            <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>
                {() => <SubmitTab ref={submitTabInputRef} />}
            </TopTab.Screen>
        )}
    </OnyxTabNavigator>

    What alternative solutions did you explore? (Optional)

    Relying only on defaultSelectedTab was considered but rejected because it does not work when a conflicting persisted tab already exists. Changing global navigator persistence behavior or reconciling state after mount was also considered but rejected due to higher risk and unnecessary complexity for this owner-level invariant.

  10. samranahm commented on Feb 5, 2026

    @samranahm
    Contributor

    Proposal

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

    Default share sheet option to Submit vs Share for all members

    What is the root cause of that problem?

    The mobile share sheet is defaulting to the Share tab instead of Submit because the OnyxTabNavigator component in ShareRootPage.tsx has no explicit defaultSelectedTab prop. When none is specified, the navigator defaults to the first declared tab, which is the Share tab.

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

    We should ensures that Submit is the initial tab shown to users by explicitly setting defaultSelectedTab={CONST.TAB.SHARE.SUBMIT} in the OnyxTabNavigator. This aligns the UI with the primary use case of the share flow—allowing users to submit expenses to themselves or others.

    defaultSelectedTab={CONST.TAB.SHARE.SUBMIT}

    here

    {isFileReady ? (
    <OnyxTabNavigator
    id={CONST.TAB.SHARE.NAVIGATOR_ID}
    tabBar={TabSelector}
    lazyLoadEnabled
    onTabSelect={onTabSelectFocusHandler}
    >

    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.

  11. etCoderDysto commented on Feb 5, 2026

    @etCoderDysto
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-05 12:08:17 UTC.

    Proposal

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

    Default share sheet option to Submit vs Share for all members

    What is the root cause of that problem?

    1. ShareTab comes before SubmitTab here

      <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>
      {isFileScannable && <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>{() => <SubmitTab ref={submitTabInputRef} />}</TopTab.Screen>}

    2. When we select the first tab, we apply focus on the Share Tab input field, and when the second tab is selected we focus Submit Tab input field

      if (index === 0) {
      shareTabInputRef.current?.focus();
      } else if (index === 1) {
      submitTabInputRef.current?.focus();
      }

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

    1. We should swap the ShareTab and SubmitTab order here:
    {isFileScannable && <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>{() => <SubmitTab ref={submitTabInputRef} />}</TopTab.Screen>}
    <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>

    <TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>
    {isFileScannable && <TopTab.Screen name={CONST.TAB.SHARE.SUBMIT}>{() => <SubmitTab ref={submitTabInputRef} />}</TopTab.Screen>}

    2. We should swap submitTabInputRef and shareTabInputRef usage here so the correct input is focused when transitioning between tabs. Since now the first tab is Submit Tab we should focus submit tab's input when first tab is pressed and we should focus Share Tab when the second tab is pressed. Note: if we don't apply this change the right input fields won't be focused and it will cause a regression.

    if (index === 0) {
        submitTabInputRef.current?.focus();
    } else if (index === 1) {
        shareTabInputRef.current?.focus();
    }

    if (index === 0) {
    shareTabInputRef.current?.focus();
    } else if (index === 1) {
    submitTabInputRef.current?.focus();
    }

    1. We can pass CONST.TAB.SHARE.SUBMIT as defaultSelectedTab of OnyxTabNavigator to use SubmitTab as the default when selectedTab is not available in Onyx:
      const [focusTrapContainerElementMapping, setFocusTrapContainerElementMapping] = useState<Record<string, HTMLElement>>({});
      const [selectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${id}`, {canBeMissing: true});
      const tabNames = useMemo(() => getTabNames(children), [children]);
      const validInitialTab = selectedTab && tabNames.includes(selectedTab) ? selectedTab : defaultSelectedTab;
    • When we first navigate to submit tab, we update the selected tab to SubmitTab below. IMO it is not necessary to pass CONST.TAB.SHARE.SUBMIT to defaultSelectedTab if we change the order of the tabs here
      if (newSelectedTab) {
      Tab.setSelectedTab<TTabName>(id, newSelectedTab as TTabName);
    POC
    Screen.Recording.2026-02-05.at.2.49.21.in.the.afternoon.mp4

    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.

  12. 54 remaining items

  13. JmillsExpensify commented on Apr 9, 2026

    @JmillsExpensify
    ContributorAuthor

    Just tested this, works like a dream. Nice work!

  14. added
    Daily
    and removed
    Weekly
    on Apr 15, 2026
  15. JmillsExpensify commented on Apr 16, 2026

    @JmillsExpensify
    ContributorAuthor

    Payment summary:

  16. JmillsExpensify commented on Apr 16, 2026

    @JmillsExpensify
    ContributorAuthor

    Regression test created and contributors paid via ND

  17. eVoloshchak commented on Apr 16, 2026

    @eVoloshchak
    Contributor

    @JmillsExpensify, this has caused a regression (#87365), which was fixed by a follow-up PR (#87407), the payment should be reduced

  18. JmillsExpensify commented on Apr 16, 2026

    @JmillsExpensify
    ContributorAuthor

    Thanks updated

  19. JmillsExpensify commented on May 5, 2026

    @JmillsExpensify
    ContributorAuthor

    $125 approved for @eVoloshchak

  20. quinthar commented on May 12, 2026

    @quinthar
    Contributor

    Approved $125 for @daledah

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions