App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Digits - The background page switches to the Workspace Overview after reloading the page

Open applause-bot[bot] opened this issue 2 weeks ago β€’ 21 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.5.36-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/105040 Email or phone of affected tester (no customers): n/a Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5.1 Safari App Component: Workspace Settings

Action Performed:

  1. Go to https://staging.new.expensify.com
  2. Login with [email protected]
  3. Go to Workspaces
  4. Create a control workspace with EUR currency
  5. Navigate to Workspaces > [Workspace] > Accounting
  6. Click Connect on Digits
  7. Verify that the "Update workspace currency?" modal appears, and that "Update workspace currency" opens the workspace currency page.
  8. Reload the page

Expected Result:

The background page should remain on the same page after reloading

Actual Result:

The background page switches to the Workspace Overview after reloading the page

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [x] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/a54d15a5-19e1-499a-a155-897caa414fa2

View all open jobs on GitHub

Applause Internal Information Exported by: Mita Rachim Bug ID: 7311791

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 12 '26 02:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/4a59b239a6c21ba7b717a1c112d59539eb491bbdbd0a8b9a59efd0e0ff35374d

applause-bot[bot] avatar Nov 12 '26 02:11 applause-bot[bot]

You have been assigned to this deploy blocker because you recently merged this PR: https://github.com/Expensify/App/pull/105040

melvin-bot[bot] avatar Nov 12 '26 02:11 melvin-bot[bot]

@lakchote @truph01 you have been assigned to this deploy blocker because you reviewed the offending PR: https://github.com/Expensify/App/pull/105040

melvin-bot[bot] avatar Nov 12 '26 02:11 melvin-bot[bot]

@daledah you have been assigned to this deploy blocker because you authored the offending PR: https://github.com/Expensify/App/pull/105040

melvin-bot[bot] avatar Nov 12 '26 02:11 melvin-bot[bot]

πŸ’¬ A slack conversation has been started in #expensify-open-source

melvin-bot[bot] avatar Nov 12 '26 02:11 melvin-bot[bot]

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

github-actions[bot] avatar Nov 12 '26 02:11 github-actions[bot]

πŸ€– Web test steps verification results: ⚠️ partial

Verified on dev NewDot web and created a Control workspace with EUR. Accounting navigation was absent, blocking the Digits flow; reload was explicitly prohibited by session policy.

Created workspace Overview showing EUR and Control; Accounting navigation absent
Step Status
1. Confirm environmentUsed the supplied web session on dev, not staging; this does not establish staging behavior.
βœ…
2. Confirm authenticationConfirmed the supplied signed-in account without switching accounts.
βœ…
3. Open WorkspacesOpened the workspace list.
βœ…
4. Create a Control workspace with EURConfirmed EUR default currency and Control plan.
Created workspace Overview showing EUR and Control; Accounting navigation absent
βœ…
5. Open AccountingAccounting navigation was absent, including after re-entering the workspace.
⚠️
6. Click Digits ConnectBlocked because Accounting was unreachable.
⚠️
7. Verify the currency prompt and Accounting backgroundNot verified in the browser. Source investigation identifies the introducing change as Add Digits connector entry and OAuth setup flow: ConnectToDigitsFlow:42–55 opens the shared Overview currency route without preserving Accounting as the originating page.
⚠️
8. Verify the background after reloadReload was prohibited by session policy, so reproduction remains unconfirmed. The source-level mechanism explains the report: the currency route belongs to Overview, and reload reconstructs navigation from the URL, losing the live Accounting background.
Recommendation: Roll forward with a route that preserves Accounting context; leave existing Overview entry points unchanged. Validate refresh and close/back from both entry points. Keep DeployBlockerCash pending validation. Globally remapping the shared currency route would break Overview callers.
⚠️

view run Β· view recording

MelvinBot avatar Nov 12 '26 02:11 MelvinBot

https://github.com/user-attachments/assets/db42d983-b2e8-4c7e-8a66-f5273c264114

Removing the blocker label since it’s behind a beta and this issue also occurs on other pages

daledah avatar Nov 12 '26 04:11 daledah

@MelvinBot please post a proposal

daledah avatar Nov 12 '26 04:11 daledah

Current assignees @truph01 and @daledah are eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] avatar Nov 12 '26 04:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022120733971442721904

melvin-bot[bot] avatar Nov 12 '26 04:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

The currency editor uses an Overview-owned URL even when opened from Accounting. Accounting remains behind the editor only in the current navigation history. After refresh, the URL reconstructs Overview instead.

This is a shared navigation limitation also affecting other currency-editor entry points, not unique to Digits.

Code evidence

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

Use an origin-preserving dynamic currency route for non-Overview entry points, following the existing navigation pattern.

  1. Register the dynamic currency screen and update Accounting/Digits, Workflows, Invoices, and Expensify Card callers to use it.
  2. Reuse the existing currency editor, deriving its background and return destination from the originating route.
  3. Preserve that destination through the nested government-rate country selector and currency-save completion. Keep reimbursement and card-enrollment continuation parameters intact.
  4. Leave existing Overview currency URLs unchanged.

Add regression coverage for refresh, close/back, and save from each origin, including the nested country selector and existing Overview flow.

Implementation guidance and validation limits

The navigation guide:749–765 recommends dynamic routes for shared screens. The country selector:31–46 currently returns explicitly to Overview and must preserve the origin too.

This proposal is source-supported, not browser-confirmed: the previous test could not reach Accounting and did not verify refresh.

What alternative solutions did you explore? (Optional)

An Accounting-specific currency route would fix the Digits entry point but leave other affected callers unchanged. Globally changing the shared route’s background would break Overview callers. Dynamic routing addresses the broader problem without adding deprecated backTo parameters.


Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](hyperlink) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Nov 12 '26 04:11 MelvinBot

Proposal

What is the root cause of that problem?

The currency editor opens on an Overview-owned URL even when the user reaches it from Accounting, so the origin is lost on refresh. ConnectToDigitsFlow navigates to ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID) (workspaces/:policyID/overview/currency) with no record that it was opened from Accounting, and WORKSPACE_TO_RHP.ts pins SCREENS.WORKSPACE.CURRENCY (and CURRENCY_GOVERNMENT_RATE_COUNTRY) under SCREENS.WORKSPACE.PROFILE (Overview). While the app is running, Accounting survives underneath only in the live navigation history; after a reload getMatchingFullScreenRoute rebuilds state from the URL alone and resolves Overview as the background. The nested government-rate country selector has the same hard-coded origin: goBackToCurrencyPage in WorkspaceOverviewCurrencyGovernmentRateCountryPage.tsx returns explicitly to the Overview currency route.

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

Follow the DYNAMIC_IMPORTED_MEMBERS_ROLE precedent already in the codebase: that shared screen is deliberately left out of WORKSPACE_TO_RHP.ts so the dynamic base-path branch decides its background from the originating pane.

  1. Register a dynamic currency screen (e.g. DYNAMIC_WORKSPACE_CURRENCY, plus a dynamic government-rate-country screen) in DYNAMIC_ROUTES / linkingConfig/config.ts with params {policyID}, mirroring DYNAMIC_IMPORTED_MEMBERS_ROLE, and remove CURRENCY and CURRENCY_GOVERNMENT_RATE_COUNTRY from the PROFILE list in WORKSPACE_TO_RHP.ts so getMatchingFullScreenRoute resolves the background from the originating central pane (Accounting, Workflows, Invoices, Card) instead of forcing Overview. Leave ROUTES.WORKSPACE_OVERVIEW_CURRENCY untouched so existing Overview deep links keep working.
  2. Point the non-Overview callers at the dynamic route: ConnectToDigitsFlow (Digits), plus the Workflows, Invoices and Expensify Card currency entry points.
  3. Thread the origin through the nested government-rate country selector: replace its hard-coded return to the Overview route with a return to the dynamic currency route, so back/save from the country step lands on the same origin.
  4. Keep the reimbursement and card-enrolment continuation params (isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment) intact through the dynamic route.

What will I verify?

Repro the issue steps on staging web (Control workspace with EUR β†’ Accounting β†’ Connect on Digits β†’ "Update workspace currency" β†’ reload: background must stay on Accounting), plus refresh, close/back and save from each origin (Accounting, Workflows, Invoices, Card) and the existing Overview flow, including the nested country-selector path, with regression coverage for each.

Contributor details

  • Expensify email: [email protected]
  • Upwork profile: https://www.upwork.com/freelancers/~01c5c6bc0e7d162f7b

khizzcr7 avatar Nov 12 '26 06:11 khizzcr7

Proposal

What is the root cause of that problem?

ConnectToDigitsFlow opens ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID) with no backTo. https://github.com/Expensify/App/blob/f3538e5728146439c4decfbad05907b2f079f826/src/components/ConnectToDigitsFlow/index.tsx#L54 On reload the URL is /workspaces/:id/overview/currency. getMatchingFullScreenRoute can only use the static WORKSPACE_TO_RHP relation, which puts SCREENS.WORKSPACE.CURRENCY under the Profile (Overview) screen. https://github.com/Expensify/App/blob/f3538e5728146439c4decfbad05907b2f079f826/src/libs/Navigation/helpers/getMatchingFullScreenRoute.ts#L161-L178 The same function already rebuilds the background from a backTo query param for non-dynamic screens, which is how other RHP screens survive a reload. https://github.com/Expensify/App/blob/f3538e5728146439c4decfbad05907b2f079f826/src/libs/Navigation/helpers/getMatchingFullScreenRoute.ts#L69-L90 The Overview currency route's getRoute and the currency page never accept or pass a backTo, so no caller can tell the reload which page was underneath. https://github.com/Expensify/App/blob/f3538e5728146439c4decfbad05907b2f079f826/src/ROUTES.ts#L3257-L3272 Workflows and Invoices open the same route the same way, so they lose their background the same way.

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

  • In ROUTES.ts, let WORKSPACE_OVERVIEW_CURRENCY.getRoute take an optional backTo and add it to the query string (the repo already has getUrlWithBackToParam). Do the same for WORKSPACE_OVERVIEW_CURRENCY_GOVERNMENT_RATE_COUNTRY, which keeps the same background.
  • Add backTo to the params type of SCREENS.WORKSPACE.CURRENCY and CURRENCY_GOVERNMENT_RATE_COUNTRY in libs/Navigation/types.ts.
  • In ConnectToDigitsFlow, call getRoute(policyID, {backTo: ROUTES.POLICY_ACCOUNTING.getRoute(policyID)}). After a reload getMatchingFullScreenRoute then resolves Accounting as the background.
  • In WorkspaceOverviewCurrencyPage, read route.params.backTo. Pass it to applyWorkspaceCurrencyChange (the hook already accepts backTo) and to the government-rate-country route, and use it for the header back button.
  • Optionally pass backTo from the Workflows and Invoices callers too, so they behave the same way.
  • Add a unit test next to the existing navigation tests (getMatchingFullScreenRoute): for workspaces/1/overview/currency?backTo=workspaces/1/accounting, the matched full-screen route is the Accounting screen. Without backTo it stays Overview.

What alternative solutions did you explore? (Optional)

  • Add a new dynamic route for the currency page with entryScreens. This gives a clean URL but needs a new route and screen, and the shared currency page has several entry points.
  • Special-case Digits inside getMatchingFullScreenRoute. This hides the symptom at the read site and can't tell which page was underneath.

haiquywork avatar Nov 12 '26 06:11 haiquywork

Proposal

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

In Workspace Settings > Accounting, clicking Connect on Digits opens the "Update workspace currency?" modal. Clicking "Update workspace currency" navigates to the currency editor RHP. When the page is reloaded in the browser, the background fullscreen page switches to Workspace Overview instead of remaining on Accounting.

What is the root cause of that problem?

In src/components/ConnectToDigitsFlow/index.tsx:54:

Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID));

ConnectToDigitsFlow opens the currency editor without passing backTo. On page reload, getMatchingFullScreenRoute.ts:60 checks isRouteWithBackToParam(route). Because backTo is missing from the URL search params, it falls through to RHP_TO_WORKSPACE[route.name] (line 173). In src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts:16, SCREENS.WORKSPACE.CURRENCY is statically mapped under SCREENS.WORKSPACE.PROFILE (Overview). Consequently, the background fullscreen route is reconstructed as Overview rather than Accounting.

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

  1. In src/ROUTES.ts, update ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute to accept optional backTo?: string:
WORKSPACE_OVERVIEW_CURRENCY: {
    route: 'workspaces/:policyID/overview/currency',
    getRoute: (
        policyID: string,
        {isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment, backTo}: {isForcedToChangeCurrency?: boolean; shouldStartExpensifyCardEnrollment?: boolean; backTo?: string} = {},
    ) => {
        const params = new URLSearchParams();
        if (isForcedToChangeCurrency) {
            params.set('isForcedToChangeCurrency', 'true');
        }
        if (shouldStartExpensifyCardEnrollment) {
            params.set('shouldStartExpensifyCardEnrollment', 'true');
        }
        if (backTo) {
            params.set('backTo', backTo);
        }
        const query = params.toString();
        return `workspaces/${policyID}/overview/currency${query ? `?${query}` : ''}` as const;
    },
},
  1. In src/components/ConnectToDigitsFlow/index.tsx:54, pass the current accounting route as backTo:
Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID, {backTo: ROUTES.WORKSPACE_ACCOUNTING.getRoute(policyID)}));
  1. In src/pages/workspace/WorkspaceOverviewCurrencyPage.tsx: Pass route.params?.backTo to Navigation.goBack on the header back button and selection dismiss so back navigation returns to Accounting.

On reload, getMatchingFullScreenRoute.ts:60-84 automatically detects backTo in the URL query params, parses ROUTES.WORKSPACE_ACCOUNTING, and reconstructs SCREENS.WORKSPACE.ACCOUNTING behind the RHP without modifying static WORKSPACE_TO_RHP relations.

What alternative solutions did you explore? (Optional)

Modifying WORKSPACE_TO_RHP.ts or getMatchingFullScreenRoute directly would break standard navigation where Currency is opened from Overview. Utilizing the existing isRouteWithBackToParam mechanism in getMatchingFullScreenRoute is the cleanest, surgical pattern already established in the app.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01a7e49dd3ec2ddd6c

psfazila02-hub avatar Nov 12 '26 07:11 psfazila02-hub

βœ… Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 12 '26 07:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

  1. Missing backTo in Navigation Call (src/components/ConnectToDigitsFlow/index.tsx:54):

    Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID));
    

    ConnectToDigitsFlow navigates to ROUTES.WORKSPACE_OVERVIEW_CURRENCY without specifying a backTo parameter.

  2. Full-screen Reconstruction on Browser Reload (src/libs/Navigation/helpers/getMatchingFullScreenRoute.ts:60–175):

    • On page refresh, getMatchingFullScreenRoute reconstructs the underlying fullscreen page behind the RHP modal.
    • At line 60, it checks if (isRouteWithBackToParam(route)). Because backTo is missing from the URL search query, it skips dynamic derivation from backTo and falls back to static RHP relations at line 173 (RHP_TO_WORKSPACE[route.name]).
    • In src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts:16, SCREENS.WORKSPACE.CURRENCY is statically declared as a sub-route of SCREENS.WORKSPACE.PROFILE (Workspace Overview).
    • Consequently, the browser reconstructs Workspace Overview behind the RHP instead of the Accounting page from which the user initiated the connection.
  3. Existing Pre-built Infrastructure Already Handles backTo:

    • In src/hooks/useApplyWorkspaceCurrencyChange.ts:32, ApplyWorkspaceCurrencyChangeOptions already defines backTo?: Route and lines 78–82 already execute:
      if (backTo) {
          Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.goBack(backTo));
          return;
      }
      
    • However, ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute does not expose backTo in its parameter options, and WorkspaceOverviewCurrencyPage does not pass route.params?.backTo into applyWorkspaceCurrencyChange or HeaderWithBackButton.onBackButtonPress.

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

1. Update ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute in src/ROUTES.ts

Accept optional backTo?: Route and serialize it into query parameters:

     WORKSPACE_OVERVIEW_CURRENCY: {
         route: 'workspaces/:policyID/overview/currency',
         getRoute: (
             policyID: string,
            {isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment, backTo}: {isForcedToChangeCurrency?: boolean; shouldStartExpensifyCardEnrollment?: boolean; backTo?: Route} = {},
         ) => {
             const params = new URLSearchParams();
             if (isForcedToChangeCurrency) {
                 params.set('isForcedToChangeCurrency', 'true');
             }
             if (shouldStartExpensifyCardEnrollment) {
                 params.set('shouldStartExpensifyCardEnrollment', 'true');
             }
            if (backTo) {
                params.set('backTo', backTo);
            }
             const query = params.toString();
             return `workspaces/${policyID}/overview/currency${query ? `?${query}` : ''}` as const;
         },
     },

2. Pass backTo in ConnectToDigitsFlow (src/components/ConnectToDigitsFlow/index.tsx:54)

         if (shouldBlockCurrencyChange || result.action !== ModalActions.CONFIRM) {
             return;
         }
        Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID, {backTo: ROUTES.WORKSPACE_ACCOUNTING.getRoute(policyID)}));
     };

3. Connect backTo in src/pages/workspace/WorkspaceOverviewCurrencyPage.tsx

Ensure selecting a currency or tapping Back returns to backTo (Accounting):

     const isForcedToChangeCurrency = !!route.params?.isForcedToChangeCurrency;
     const shouldStartExpensifyCardEnrollment = !!route.params?.shouldStartExpensifyCardEnrollment;
    const backTo = route.params?.backTo;
     const shouldBlockCurrencyChange = useShouldBlockCurrencyChange(policy?.id);
     const {showConfirmModal} = useConfirmModal();
     const applyWorkspaceCurrencyChange = useApplyWorkspaceCurrencyChange(policy);

     const applyCurrencySelection = (currencyCode: string) => {
        applyWorkspaceCurrencyChange(currencyCode, {isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment, backTo});
     };
             >
                 <HeaderWithBackButton
                     title={translate('workspace.editor.currencyInputLabel')}
                    onBackButtonPress={() => Navigation.goBack(backTo)}
                 />

Why this completely fixes the reload behavior:

In src/libs/Navigation/helpers/getMatchingFullScreenRoute.ts:60–84, when the page reloads, isRouteWithBackToParam(route) evaluates to true because ?backTo=workspaces%2F<policyID>%2Faccounting is in the URL. getMatchingFullScreenRoute extracts backTo, resolves it via getAdaptedStateFromPath, and mounts SCREENS.WORKSPACE.ACCOUNTING behind the RHP. Static relations in WORKSPACE_TO_RHP.ts remain completely untouched and standard Overview -> Currency navigation continues to work without regression.


What alternative solutions did you explore? (Optional)

  • Modifying static WORKSPACE_TO_RHP.ts or hardcoding Digits in getMatchingFullScreenRoute: Mapping SCREENS.WORKSPACE.CURRENCY under Accounting would break standard workspace profile settings where Currency is edited from Overview. Utilizing Expensify's canonical backTo query param mechanism in getMatchingFullScreenRoute is dynamic, safe, and leverages already-implemented code in useApplyWorkspaceCurrencyChange.

What automated tests can you add to prevent this from re-occurring?

In tests/unit/ConnectToDigitsFlowTest.tsx: Verify that when promptCurrencyChange confirms, Navigation.navigate is invoked with ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID, {backTo: ROUTES.WORKSPACE_ACCOUNTING.getRoute(policyID)}).

In tests/navigation/getMatchingFullScreenRouteTest.ts: Verify that an RHP currency route with backTo=workspaces/:policyID/accounting returns the Accounting screen as the underlying full-screen route on cold reload.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 12 '26 11:11 kevinjosh10

βœ… Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 12 '26 11:11 melvin-bot[bot]

Proposal

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

When navigating to Workspaces > [Workspace] > Accounting on a non-USD workspace, clicking Connect on Digits opens the "Update workspace currency?" modal, and confirming navigates to the workspace currency selector RHP. However, when the browser page is reloaded while the currency RHP is open, the background full-screen page switches from Accounting to Overview.

What is the root cause of that problem?

  1. In src/components/ConnectToDigitsFlow/index.tsx:54, promptCurrencyChange navigates to the static Overview-owned currency route:
    Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policyID));
    
    (The same pattern is used in src/pages/workspace/workflows/tabs/WorkflowsPaymentsTab.tsx:140, src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx:91, and src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx:126.)
  2. Because ROUTES.WORKSPACE_OVERVIEW_CURRENCY produces /workspaces/:policyID/overview/currency, the originating screen context (Accounting, Workflows, Invoices, or Expensify Card) exists only in in-memory navigation state.
  3. On a browser reload, getAdaptedStateFromPath (src/libs/Navigation/helpers/getAdaptedStateFromPath.ts:143) calls getMatchingFullScreenRoute(focusedRoute, true). Since SCREENS.WORKSPACE.CURRENCY (and SCREENS.WORKSPACE.CURRENCY_GOVERNMENT_RATE_COUNTRY) are static screens mapped under SCREENS.WORKSPACE.PROFILE in src/libs/Navigation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts:15-17, getMatchingFullScreenRoute reconstructs SCREENS.WORKSPACE.PROFILE (Overview) as the background full-screen route.
  4. Furthermore, when auto-updating government distance rates is enabled and a shared currency (EUR) is selected, WorkspaceOverviewCurrencyPage.tsx:56-61 navigates to ROUTES.WORKSPACE_OVERVIEW_CURRENCY_GOVERNMENT_RATE_COUNTRY, and WorkspaceOverviewCurrencyGovernmentRateCountryPage.tsx:33,45 hardcodes ROUTES.WORKSPACE_OVERVIEW.getRoute(policyID) as its backTo destination upon saving.

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

Per contributingGuides/NAVIGATION.md:749-765 and the lint rule in src/libs/Navigation/paramLists/WorkspaceSettingsParamList.ts:82 ("Do not add new backTo params to screens"), we should convert the workspace currency selector and its nested government-rate country selector to dynamic routes (matching DYNAMIC_WORKSPACE_OVERVIEW_ADDRESS and DYNAMIC_WORKSPACE_OVERVIEW_PLAN).

Even better, because currency and currency/government-rate-country/:currencyCode under /workspaces/:policyID/overview are identical to the existing URLs (/workspaces/:policyID/overview/currency and /workspaces/:policyID/overview/currency/government-rate-country/:currencyCode), making them dynamic routes preserves the exact existing Overview URLs while automatically preserving Accounting, Workflows, Invoices, and Expensify Card as the base path (/workspaces/:policyID/accounting/currency, etc.) on reload, back, and save!

  1. Define dynamic routes in src/ROUTES.ts (DYNAMIC_ROUTES):

    WORKSPACE_CURRENCY: {
        path: 'currency',
        entryScreens: [
            SCREENS.WORKSPACE.PROFILE,
            SCREENS.WORKSPACE.ACCOUNTING.ROOT,
            SCREENS.WORKSPACE.WORKFLOWS,
            SCREENS.WORKSPACE.INVOICES,
            SCREENS.WORKSPACE.EXPENSIFY_CARD,
        ],
        getRoute: ({isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment}: {isForcedToChangeCurrency?: boolean; shouldStartExpensifyCardEnrollment?: boolean} = {}) =>
            getUrlWithParams('currency', {
                isForcedToChangeCurrency: isForcedToChangeCurrency ? 'true' : undefined,
                shouldStartExpensifyCardEnrollment: shouldStartExpensifyCardEnrollment ? 'true' : undefined,
            }),
        queryParams: ['isForcedToChangeCurrency', 'shouldStartExpensifyCardEnrollment'],
    },
    WORKSPACE_CURRENCY_GOVERNMENT_RATE_COUNTRY: {
        path: 'government-rate-country/:currencyCode',
        entryScreens: [SCREENS.WORKSPACE.DYNAMIC_WORKSPACE_CURRENCY],
        getRoute: (
            currencyCode: string,
            {isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment}: {isForcedToChangeCurrency?: boolean; shouldStartExpensifyCardEnrollment?: boolean} = {},
        ) =>
            getUrlWithParams(`government-rate-country/${currencyCode}`, {
                isForcedToChangeCurrency: isForcedToChangeCurrency ? 'true' : undefined,
                shouldStartExpensifyCardEnrollment: shouldStartExpensifyCardEnrollment ? 'true' : undefined,
            }),
        queryParams: ['isForcedToChangeCurrency', 'shouldStartExpensifyCardEnrollment'],
    },
    
  2. Register the dynamic screens in src/SCREENS.ts, src/libs/Navigation/paramLists/WorkspaceSettingsParamList.ts, src/libs/Navigation/linkingConfig/config.ts, and src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx:

    • Rename SCREENS.WORKSPACE.CURRENCY β†’ SCREENS.WORKSPACE.DYNAMIC_WORKSPACE_CURRENCY ('Dynamic_Workspace_Overview_Currency') and SCREENS.WORKSPACE.CURRENCY_GOVERNMENT_RATE_COUNTRY β†’ SCREENS.WORKSPACE.DYNAMIC_WORKSPACE_CURRENCY_GOVERNMENT_RATE_COUNTRY ('Dynamic_Workspace_Overview_Currency_Government_Rate_Country'), and include policyID: string in WorkspaceSettingsParamList (merged automatically from the underlying entry screen by getStateFromPath.ts:51-54).
    • Remove CURRENCY and CURRENCY_GOVERNMENT_RATE_COUNTRY from WORKSPACE_TO_RHP.ts so getDynamicRouteAdaptedState (src/libs/Navigation/helpers/dynamicRoutesUtils/getDynamicRouteAdaptedState.ts:78-118) and getMatchingFullScreenRoute (src/libs/Navigation/helpers/getMatchingFullScreenRoute.ts:232-265) strip the dynamic suffixes (government-rate-country/:currencyCode and currency) and reconstruct the exact originating full-screen route (Accounting, Overview, Workflows, Invoices, or Expensify Card) underneath the RHP on reload.
  3. Update WorkspaceOverviewCurrencyPage.tsx and WorkspaceOverviewCurrencyGovernmentRateCountryPage.tsx to use useDynamicBackPath:

    • In src/pages/workspace/WorkspaceOverviewCurrencyPage.tsx:
      const backPath = useDynamicBackPath(DYNAMIC_ROUTES.WORKSPACE_CURRENCY.path);
      
      • Pass backTo: backPath into applyWorkspaceCurrencyChange(currencyCode, {isForcedToChangeCurrency, shouldStartExpensifyCardEnrollment, backTo: backPath}).
      • Use Navigation.goBack(backPath) for HeaderWithBackButton's onBackButtonPress and fullPageNotFoundViewProps.onLinkPress.
      • When navigating to the government-rate country selector for shared EUR currencies, call:
        Navigation.navigate(
            createDynamicRoute(
                DYNAMIC_ROUTES.WORKSPACE_CURRENCY_GOVERNMENT_RATE_COUNTRY.getRoute(item.currencyCode, {
                    isForcedToChangeCurrency,
                    shouldStartExpensifyCardEnrollment,
                }),
            ),
        );
        
    • In src/pages/workspace/WorkspaceOverviewCurrencyGovernmentRateCountryPage.tsx:
      const currencyBackPath = useDynamicBackPath(DYNAMIC_ROUTES.WORKSPACE_CURRENCY_GOVERNMENT_RATE_COUNTRY.path);
      const originBackPath = stripDynamicRouteSuffixFromPath(currencyBackPath, DYNAMIC_ROUTES.WORKSPACE_CURRENCY.path);
      
      • Use Navigation.goBack(currencyBackPath) in goBackToCurrencyPage.
      • Pass backTo: originBackPath (instead of hardcoded ROUTES.WORKSPACE_OVERVIEW.getRoute(policyID)) to applyWorkspaceCurrencyChange in saveCountry.
  4. Update callers to navigate via createDynamicRoute:

    • src/components/ConnectToDigitsFlow/index.tsx:54:
      Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CURRENCY.path, ROUTES.POLICY_ACCOUNTING.getRoute(policyID)));
      
    • src/pages/workspace/WorkspaceOverviewPage.tsx:167:
      Navigation.navigate(buildDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CURRENCY.path));
      
    • src/pages/workspace/workflows/tabs/WorkflowsPaymentsTab.tsx:140:
      Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CURRENCY.getRoute({isForcedToChangeCurrency: true}), ROUTES.WORKSPACE_WORKFLOWS.getRoute(policy.id)));
      
    • src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx:91:
      Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CURRENCY.getRoute({isForcedToChangeCurrency: true}), ROUTES.WORKSPACE_INVOICES.getRoute(policy.id)));
      
    • src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx:126:
      Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CURRENCY.getRoute({shouldStartExpensifyCardEnrollment: true}), ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policy.id)));
      

What alternative solutions did you explore? (Optional)

  • Adding a backTo query parameter to ROUTES.WORKSPACE_OVERVIEW_CURRENCY: Explicitly discouraged by contributingGuides/NAVIGATION.md and WorkspaceSettingsParamList.ts:82 (no-restricted-syntax -- backTo usages in this file are legacy. Do not add new backTo params to screens).
  • Keeping CURRENCY in WORKSPACE_TO_RHP.ts while adding a dynamic route: Any screen remaining in RHP_TO_WORKSPACE hits the if (RHP_TO_WORKSPACE[route.name]) branch in getMatchingFullScreenRoute.ts:166 before reaching the dynamic route branch at line 232, which would still force SCREENS.WORKSPACE.PROFILE on reload. Removing it from WORKSPACE_TO_RHP.ts (just like DYNAMIC_IMPORTED_MEMBERS_ROLE) ensures dynamic base-path resolution works on both cold reload and stacked country selection.

Contributor Details

  • Expensify Account Email: [email protected]
  • Upwork Profile Link: https://www.upwork.com/freelancers/~0105c450e4a0cf3079

cocvn157 avatar Nov 13 '26 07:11 cocvn157

daledah fixed this in https://github.com/Expensify/App/pull/106748, which has been on production since Nov 18. It's part of the Digits project, which gets paid in one issue at the end like Zoho Books, so I'm adding Skip Payment and closing this.

lakchote avatar Nov 26 '26 16:11 lakchote