Prevent infinite spinner when no transactions to load#94740
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c0e1a978e
ℹ️ 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".
| transactions?.length === 0 && | ||
| ((!!reportLoadingState?.isLoadingInitialReportActions && !reportLoadingState.hasOnceLoadedReportActions) || report?.total !== 0 || hasPendingDismissWrite); | ||
| ((!!reportLoadingState?.isLoadingInitialReportActions && !hasFinishedInitialReportActionsLoad) || | ||
| (report?.total !== 0 && !hasFinishedInitialReportActionsLoad) || |
There was a problem hiding this comment.
Keep waiting while transactions can still populate
When hasOnceLoadedReportActions flips true before the derived transactions collection has caught up, this now stops waiting even though report.total still says the money request has expenses. useReportTransactionsCollection returns an empty object until REPORT_TRANSACTIONS_AND_VIOLATIONS is recomputed, and MoneyRequestReportActionsList treats empty actions plus empty transactions as the empty-state view once isLoadingInitialReportActions is false, so a normal non-empty report can briefly or incorrectly render as empty instead of continuing to show the skeleton until its transactions arrive.
Useful? React with 👍 / 👎.
Explanation of Change
shouldWaitForTransactionskept a money-request/invoice report in the loading state whenever its cachedtotalwas non-zero and no transactions were present. If a report's transactions can never load (e.g. the owning report was orphaned by an account merge), this showed the loading skeleton forever. Now, once the initial report actions have loaded at least once (hasOnceLoadedReportActions) and still no transactions arrived, we stop treating a staletotalas "still loading", so the report resolves to its empty/not-found state instead of spinning. The pre-load window (waiting while actions are still loading) is unchanged, so there is no empty-state flash on normal reports.This is a defense-in-depth companion to the backend fix in Auth#22541.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/645644
PROPOSAL:
Tests
tests/unit/libs/MoneyRequestReportUtils.tscoversshouldWaitForTransactions(waits while loading / before first load, stops once loaded with no transactions, never waits offline). Runnpx jest tests/unit/libs/MoneyRequestReportUtils.ts— 13/13 pass.Offline tests
QA Steps
Same as Tests, using the affected account/expense from the linked issue. A clean reproduction requires an expense whose owning report was orphaned by an account merge; on a normal report, confirm there is no regression (transactions load, no empty-state flash).
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari