You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2025-12-03] [$250] Expense - After clearing cache, starting per diem flow shows empty state page briefly #74272
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
The component then fetches the per diem rates via fetchPerDiemRates in the useEffect, but there's no loading state tracking this fetch operation. The isLoading variable only tracks policyMetadata loading status, not the per diem rates fetch
After clear cache and restart, customUnit?.rates will be undefined, so the loading will show. After loaded, if the rates is empty, !customUnit?.rates will evaluate to false, so the loading won't show if the rates is empty.
changed the title [-]Expense - After clearing cache, starting per diem flow shows empty state page briefly[/-][+][$250] Expense - After clearing cache, starting per diem flow shows empty state page briefly[/+]on Nov 6, 2025
Please re-state the problem that we are trying to solve in this issue.
After clearing cache and starting the per diem expense creation flow, an empty state page is briefly displayed before the per diem destination picker appears. The expected behavior is that the empty state should not appear at all when starting the per diem flow after clearing cache.
What is the root cause of that problem?
The issue occurs because when cache is cleared, the per diem rates are not yet loaded in Onyx when the IOURequestStepDestination component mounts. The component checks if customUnit?.rates is empty and immediately shows the empty state page, even though rates are being fetched asynchronously.
The logic flow is:
Component mounts with empty rates (cache was cleared)
shouldShowEmptyState evaluates to true because isEmptyObject(customUnit?.rates) is true
Empty state is rendered briefly
useEffect then calls fetchPerDiemRates() to load the rates
Once rates are loaded, the empty state disappears and the destination picker is shown
The problem is that the component doesn't distinguish between:
Rates are loading (after cache clear) → should show loading indicator
Rates are truly empty (no rates configured) → should show empty state
What changes do you think we should make in order to solve the problem?
Add logic to track whether we've initiated a fetch for per diem rates, and show a loading state instead of empty state when rates are expected but not yet loaded.
Pseudo Code:
// Track if we've initiated a fetch to distinguish between "rates are loading" and "rates are truly empty"consthasInitiatedFetch=useRef(false);// If per diem is enabled but rates are empty, we might be loading them after cache clear// Show loading state instead of empty state to prevent brief empty state flash// Once we've fetched and confirmed rates are empty, show empty stateconstisPerDiemEnabled=policy?.arePerDiemRatesEnabled===true;// Show loading if: per diem is enabled, rates are empty, we're online, policy is loaded, // and we haven't confirmed rates are empty yetconstisRatesLoading=isPerDiemEnabled&&isEmptyObject(customUnit?.rates)&&!isOffline&&!isLoadingOnyxValue(policyMetadata)&&!hasInitiatedFetch.current;// Only show empty state if rates are empty AND we've already initiated fetch // (meaning we've confirmed they're truly empty)constshouldShowEmptyState=isEmptyObject(customUnit?.rates)&&!isOffline&&hasInitiatedFetch.current;// In the useEffect that fetches rates:useEffect(()=>{if(!isEmptyObject(customUnit?.rates)||isOffline){return;}hasInitiatedFetch.current=true;// Mark that we've started fetchingfetchPerDiemRates(policy?.id);},[isOffline]);// Show loading indicator when either policy is loading or rates are loading{(isLoading||isRatesLoading)&&(<ActivityIndicator/>)}
The fix:
Uses a useRef to track whether we've initiated a fetch for rates
Shows loading state when per diem is enabled but rates are empty (indicating they're being loaded)
Only shows empty state after we've confirmed rates are empty (after fetch completes)
Updates the loading indicator to show when rates are loading in addition to when policy is loading
This ensures that when cache is cleared, the component shows a loading indicator instead of briefly flashing the empty state, providing a better user experience.
What alternative solutions did you explore? (Optional)
Check if policy has per diem enabled before showing empty state: We could check policy?.arePerDiemRatesEnabled before showing empty state, but this alone doesn't distinguish between "loading" and "truly empty" states. We need to track fetch state.
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.63-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@ahmedGaber93 / @bernhardoj@RachCHopkins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Minor issue, I don't think we need a regression test here.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Nov 5, 2025
Triggered auto assignment to @RachCHopkins (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.nyomanjyotisa commentedon Nov 5, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Expense - After clearing cache, starting per diem flow shows empty state page briefly
What is the root cause of that problem?
When cache is cleared,
customUnit?.ratesbecomes empty andshouldShowEmptyStatebecomestrue.App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Lines 76 to 77 in eb1b8f1
The component then fetches the per diem rates via
fetchPerDiemRatesin the useEffect, but there's no loading state tracking this fetch operation. TheisLoadingvariable only trackspolicyMetadataloading status, not the per diem rates fetchApp/src/pages/iou/request/step/IOURequestStepDestination.tsx
Lines 124 to 130 in eb1b8f1
What changes do you think we should make in order to solve the problem?
We can add a local state to track per diem rates fetching
Then update the useEffect that fetches rates
App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Lines 124 to 130 in eb1b8f1
We also need to add another useEffect to reset loading state when rates are loaded
Then update
isLoadingandshouldShowEmptyStateto include the per diem fetch stateApp/src/pages/iou/request/step/IOURequestStepDestination.tsx
Lines 76 to 77 in eb1b8f1
What alternative solutions did you explore? (Optional)
None
paulnjs commentedon Nov 5, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
After clearing the cache, starting the per diem flow briefly displays an empty state page.
What is the root cause of that problem?
When the per diem data is loading via this call:
App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Line 128 in 5279e0b
the
shouldShowEmptyStatevariable is set totrue:App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Line 77 in 5279e0b
As a result, the empty state is shown while the per diem data is still loading.
What changes do you think we should make in order to solve the problem?
We should update the
isLoadingcalculation at:App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Line 76 in 5279e0b
to include the
isLoadingPerdiemflag. The updated logic should look like:The
isLoadingPerdiemflag is set totrueoptimistically infetchPerDiemRate, and reset tonullin bothsuccessDataandfailureData:App/src/libs/actions/Policy/PerDiem.ts
Line 395 in 5279e0b
What alternative solutions did you explore? (Optional)
bernhardoj commentedon Nov 5, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-11-18 04:46:10 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
After clearing cache and restart, per diem destination page shows empty state briefly.
What is the root cause of that problem?
The empty state view will show if the per diem custom unit rates are empty.
App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Line 77 in 4ad44ed
After clearing cache and restart, the policy object doesn't have the
customUnitsfield and only loaded here.App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Lines 124 to 130 in 4ad44ed
The loading will only show if the policy onyx data is loading.
App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Line 76 in 4ad44ed
What changes do you think we should make in order to solve the problem?
We can show the loading if the custom units is missing and prevent showing the empty state if it's loading.
App/src/pages/iou/request/step/IOURequestStepDestination.tsx
Lines 76 to 77 in f34c0e3
After clear cache and restart,
customUnit?.rateswill be undefined, so the loading will show. After loaded, if the rates is empty,!customUnit?.rateswill evaluate to false, so the loading won't show if the rates is empty.[-]Expense - After clearing cache, starting per diem flow shows empty state page briefly[/-][+][$250] Expense - After clearing cache, starting per diem flow shows empty state page briefly[/+]melvin-bot commentedon Nov 6, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021986272881400271924
melvin-bot commentedon Nov 6, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ahmedGaber93 (
External)IjaazA commentedon Nov 6, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
After clearing cache and starting the per diem expense creation flow, an empty state page is briefly displayed before the per diem destination picker appears. The expected behavior is that the empty state should not appear at all when starting the per diem flow after clearing cache.
What is the root cause of that problem?
The issue occurs because when cache is cleared, the per diem rates are not yet loaded in Onyx when the
IOURequestStepDestinationcomponent mounts. The component checks ifcustomUnit?.ratesis empty and immediately shows the empty state page, even though rates are being fetched asynchronously.The logic flow is:
shouldShowEmptyStateevaluates totruebecauseisEmptyObject(customUnit?.rates)istrueuseEffectthen callsfetchPerDiemRates()to load the ratesThe problem is that the component doesn't distinguish between:
What changes do you think we should make in order to solve the problem?
Add logic to track whether we've initiated a fetch for per diem rates, and show a loading state instead of empty state when rates are expected but not yet loaded.
Pseudo Code:
The fix:
useRefto track whether we've initiated a fetch for ratesThis ensures that when cache is cleared, the component shows a loading indicator instead of briefly flashing the empty state, providing a better user experience.
What alternative solutions did you explore? (Optional)
Check if policy has per diem enabled before showing empty state: We could check
policy?.arePerDiemRatesEnabledbefore showing empty state, but this alone doesn't distinguish between "loading" and "truly empty" states. We need to track fetch state.melvin-bot commentedon Nov 13, 2025
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
23 remaining items
melvin-bot commentedon Nov 26, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Nov 26, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.63-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2025-12-03. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Nov 26, 2025
@ahmedGaber93 / @bernhardoj @RachCHopkins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
melvin-bot commentedon Dec 3, 2025
Payment Summary
Upwork Job
BugZero Checklist (@RachCHopkins)
ahmedGaber93 commentedon Dec 4, 2025
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: https://github.com/Expensify/App/pull/54252/files#r2588366135
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Minor issue, I don't think we need a regression test here.
melvin-bot commentedon Dec 5, 2025
@RachCHopkins Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
RachCHopkins commentedon Dec 7, 2025
Payment Summary above is correct.
Contributors to be paid via NewDot, and the Upwork post has been closed.
🟢 to request payment.
bernhardoj commentedon Dec 8, 2025
Requested in ND.
garrettmknight commentedon Dec 18, 2025
$250 approved for @bernhardoj
JmillsExpensify commentedon Jan 4, 2026
$250 approved for @ahmedGaber93