Fix infinite skeleton when deleting expense and returning to self DM#83156
Fix infinite skeleton when deleting expense and returning to self DM#83156marufsharifi wants to merge 1 commit intoExpensify:mainfrom
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
| } | ||
| const {updatedState, didRemoveRouteAtRoot} = removalResult; | ||
| const routes = updatedState.routes ?? []; | ||
| const nextIndex = didRemoveRouteAtRoot ? Math.max(0, Math.min(updatedState.index ?? 0, routes.length - 1)) : updatedState.index; |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The index clamping logic here duplicates the same computation already performed inside removeReportRoutesFromState (line 861). The returned updatedState.index is already set to Math.max(0, Math.min(state.index, nextRoutes.length - 1)) when didRemoveRouteAtRoot is true, so re-clamping it here is redundant.
Since removeReportRoutesFromState already returns the correctly computed index in updatedState, you can simplify this to use updatedState.index directly:
const {updatedState, didRemoveRouteAtRoot} = removalResult;
const routes = updatedState.routes ?? [];
return CommonActions.reset({
...updatedState,
routes,
index: updatedState.index ?? 0,
});Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3cf6b4009
ℹ️ 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".
| if (reportIDFromRoute) { | ||
| Navigation.removeReportScreen(new Set([reportIDFromRoute])); | ||
| } |
There was a problem hiding this comment.
Avoid removing the next report route on stale delete state
This effect now runs when reportIDFromRoute changes, but reportWasDeleted is reset asynchronously in useReportWasDeleted (see src/pages/inbox/hooks/useReportWasDeleted.ts), so there is a render where reportWasDeleted is still true for the previous report while reportIDFromRoute already points to the new one. In that window, calling Navigation.removeReportScreen(new Set([reportIDFromRoute])) removes a valid report route and can incorrectly kick users back to fallback navigation when moving away from a deleted report in flows where ReportScreen is reused.
Useful? React with 👍 / 👎.
Explanation of Change
Navigation back to the Not Found page, then to Self DM, when the report is already deleted.
Fixed Issues
$ #71761
PROPOSAL: #71761 (Comment)
Tests
Offline tests
Same as Tests.
QA Steps
Same as Tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2026-02-22.at.5.40.08.PM.mov
Android: mWeb Chrome
Screen.Recording.2026-02-22.at.5.43.45.PM.mov
iOS: Native
Screen.Recording.2026-02-22.at.5.49.09.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-02-22.at.6.46.26.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-02-22.at.5.31.07.PM.mov