Skip to content

fix: remove per diem page loading gate that never resolves - #100956

Merged
mountiny merged 1 commit into
Expensify:mainfrom
callstack-internal:fix-perdiem-infinite-loading
Sep 14, 2026
Merged

mountiny merged 1 commit into
Expensify:mainfrom
callstack-internal:fix-perdiem-infinite-loading

Conversation

@BartekObudzinski

@BartekObudzinski BartekObudzinski commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The workspace Per Diem page inferred its loading state from data absence: const isLoading = !isOffline && customUnit === undefined;. getPerDiemCustomUnit returns undefined whenever a policy has no custom unit named PerDiemInternational, and a policy can legitimately have arePerDiemRatesEnabled: true with no such unit, so on those workspaces the spinner never stopped.

That gate could not be correct, because data absence cannot distinguish "not yet" from "never". It was also redundant: AccessOrNotFoundWrapper already holds a full-screen loader until the policy is in Onyx, and customUnits is a field on the policy object rather than something OpenPolicyPerDiemRatesPage fetches. By the time the page body renders, the answer is already final, so there is no wait to indicate.

This removes the gate and lets the table render, which shows the existing empty state (with its import-spreadsheet CTA) when a policy has no per diem rates. For any policy that does have a custom unit the behaviour is unchanged, since isLoading was already false in that case and the rows were driven by hasVisibleSubRates.

Fixed Issues

$ #100968
PROPOSAL:

Tests

  1. Sign in and open a workspace that has the Per diem feature enabled but no per diem rates configured.
  2. Go to Workspace settings > Per diem.
  3. Verify the page renders the empty state with the "Import spreadsheet" button instead of an endless spinner.
  4. Click Import spreadsheet, upload a CSV with Destination / Subrate / Currency / Amount columns, and map the four columns.
  5. Verify the rates table renders the imported rows.
  6. Navigate away and back to Per diem, and verify the rows still render with no spinner in between.
  7. Open a workspace that already has per diem rates and verify the table renders immediately, unchanged from before.
  • Verify that no errors appear in the JS console

Offline tests

  1. Open a workspace with Per diem enabled while online, then go offline.
  2. Go to Workspace settings > Per diem and verify the previously loaded rates still render from cache.
  3. Verify the offline indicator appears and the "Import spreadsheet" action shows the "you appear to be offline" modal.
  4. Go back online and verify the list refreshes without a spinner.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-09-11.at.13.56.47.mov

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...c/pages/workspace/perDiem/WorkspacePerDiemPage.tsx 0.00% <0.00%> (ø)
... and 28 files with indirect coverage changes

@huult

huult commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@BartekObudzinski Tag me when it’s ready.

@BartekObudzinski
BartekObudzinski marked this pull request as ready for review September 11, 2026 13:46
@BartekObudzinski
BartekObudzinski requested review from a team as code owners September 11, 2026 13:46
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and mountiny and removed request for a team September 11, 2026 13:46
@melvin-bot

melvin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

@mountiny Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team September 11, 2026 13:46
@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

@huult ready

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce12d3cdb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/>
)}
{!hasVisibleSubRates && subtitleContent}
<WorkspacePerDiemTable

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Provision a custom unit before exposing the import CTA

For the exact workspace state this change now exposes (arePerDiemRatesEnabled with no PerDiem custom unit), writers can tap the newly rendered empty-state Import spreadsheet button, complete the CSV mapping, and then have the import silently return: ImportedPerDiemPage.importRates requires perDiemCustomUnit.customUnitID and exits when it is absent (lines 119–123). Consequently, affected workspaces no longer spin, but still cannot add their first per-diem rate; create/provision the unit before enabling this CTA or handle the absent-unit import path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BartekObudzinski what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2026-09-11.at.23.18.20.mov

@BartekObudzinski You're right that removing isLoading fixes the infinite spinner. However, the import still doesn't work when customUnit is undefined.

I tested this case and confirmed that the import exits because perDiemCustomUnit.customUnitID is missing. Could you take another look at this? Do we need to adjust the import function to handle the missing custom unit, or should we provision the custom unit before exposing the import CTA?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, importRates exits at the !perDiemCustomUnit?.customUnitID check so nothing happens after mapping.

It's pre existing. Before this PR the spinner made the button unreachable, so the page goes from fully broken to working except that one action.

Provisioning on page render like Codex suggests would write policy state just from opening a read only page. The right place is the import itself, and it needs a backend answer on whether ImportPerDiemRates creates the unit from a customUnitID that doesn't exist yet.

Keeping this PR to the spinner. The import, and the reason these workspaces have arePerDiemRatesEnabled: true with no unit, go into a separate issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2026-09-11.at.20.16.05.mov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mountiny I need some advice on this. I can confirm the spinner issue is fixed, but I can't approve the PR yet because we found an import issue that requires the backend team to investigate and confirm the correct solution.

Could you help confirm whether we should proceed with this PR while tracking the import issue separately, or hold this PR until the backend team can provide a complete solution?

One thing I'm wondering is whether these two issues could actually have the same RCA, since both seem to be related to customUnitID being undefined. If that's the case, once the underlying issue is fixed, we wouldn't need to remove the spinner fix, right @BartekObudzinski? Just a hypothesis from my side, so I'd like to get your thoughts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both problems come from the same state: a policy that has arePerDiemRatesEnabled set to true and no PerDiemInternational custom unit.

One correction to my earlier comment. The user can still open the import while the spinner shows. secondaryActions adds Import spreadsheet to the More dropdown in the header, and the header renders outside the isLoading branch.

A fix at the data source removes the condition that starts the loading state, but it does not make the loading state correct. customUnit === undefined has no terminal condition, because an absent value cannot tell you if the data is late or if it will never arrive. Any workspace that a backfill misses will show the spinner forever.

The gate is also redundant. AccessOrNotFoundWrapper already shows a full screen loader until the policy is in Onyx, and customUnits is a field on the policy, not something that OpenPolicyPerDiemRatesPage fetches.

We confirmed that it works, so I prefer to merge it and track the import separately

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @mountiny

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot create a follow up issue for this case and assign @mountiny @BartekObudzinski @huult. Technically, we should fix it here but for urgency we wont wait with merging this pr.

@MelvinBot MelvinBot Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created the follow-up: #101066 — assigned mountiny, BartekObudzinski, and huult.

It tracks the silent import failure at ImportedPerDiemPage.tsx:122 plus the two open questions: why a policy ends up with arePerDiemRatesEnabled: true and no PerDiemInternational custom unit, and whether ImportPerDiemRates can create the unit or the App has to provision it first.

No existing issue covered this, so nothing to dedupe against.


view run · no recording available

@huult

huult commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-09-12.at.15.45.40.mov
Android: mWeb Chrome
Screen.Recording.2026-09-12.at.15.47.05.mov
iOS: HybridApp
Screen.Recording.2026-09-12.at.15.49.09.mov
iOS: mWeb Safari
Screen.Recording.2026-09-12.at.15.49.46.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-12.at.15.43.10.mov

@huult huult left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2026-09-12.at.15.43.10.mov

LGTM. (#100956 (comment))

@mountiny
mountiny merged commit 2c7fdde into Expensify:main Sep 14, 2026
47 of 71 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@melvin-bot

melvin-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

@mountiny looks like this was merged without a test passing. These checks had not passed on ce12d3c when it was merged:

Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@mountiny

Copy link
Copy Markdown
Contributor

Not an emergency, we got the ai reviewers covered with codex

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.78-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

MelvinBot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR, so I did not create a docs PR.

This change removes a loading gate (isLoading) that could never resolve on workspaces with Per diem enabled but no PerDiemInternational custom unit. It adds no feature, renames nothing, and changes no label, button, menu, or flow.

What I checked

The diff — src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx is the only file touched: the ActivityIndicator branch is deleted and WorkspacePerDiemTable renders unconditionally.

The user-visible result — the empty state that admins now reach already existed and is unchanged. Its Import spreadsheet button is defined at WorkspacePerDiemPage.tsx:347-364 and was already passed to the table before this PR. The only difference is that the spinner no longer blocks it.

The articles — both existing Per diem articles remain accurate as written:

Neither article documents loading behavior, and the help site does not describe spinners or empty states, so there is nothing to update.

@BartekObudzinski, please confirm you agree that no help site update is needed here. If you want the Per diem articles refreshed for something else (for example, to document the empty state and its Import spreadsheet action for workspaces with no rates yet), reply with @MelvinBot and what to cover, and I'll open the draft docs PR.


view run · no recording available

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.4.78-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants