-
Notifications
You must be signed in to change notification settings - Fork 4k
Roll back optimistic new-chat expense on money-request failure #96573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
37720ee
721cc53
651831d
9ad4345
471b268
ef00b98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ import {canUseTouchScreen, hasHoverSupport} from '@libs/DeviceCapabilities'; | |
| import type {OnyxDataWithErrors} from '@libs/ErrorUtils'; | ||
| import {getLatestErrorMessageField, isReceiptError} from '@libs/ErrorUtils'; | ||
| import {isReportMessageAttachment} from '@libs/isReportMessageAttachment'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import type {PlatformStackNavigationProp} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
| import type {ReportsSplitNavigatorParamList} from '@libs/Navigation/types'; | ||
| import Permissions from '@libs/Permissions'; | ||
|
|
@@ -65,6 +66,7 @@ import AttachmentModalContext from '@pages/media/AttachmentModalScreen/Attachmen | |
| import {clearAllRelatedReportActionErrors} from '@userActions/ClearReportActionErrors'; | ||
| import {hideEmojiPicker, isActive} from '@userActions/EmojiPickerAction'; | ||
| import {expandURLPreview} from '@userActions/Report'; | ||
| import deleteReport from '@userActions/Report/DeleteReport'; | ||
| import {clearError} from '@userActions/Transaction'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
|
|
@@ -259,6 +261,19 @@ function ReportActionItem({ | |
| cleanUpMoneyRequest(transactionIDToDismiss, action, reportID, transactionThreadReport, report, chatReport, undefined, originalReportID, true, iouPolicy); | ||
| return; | ||
| } | ||
|
|
||
| // When the expense created a brand-new chat that failed to be created on the server, the chat, IOU report and | ||
| // everything created solely for this request are orphaned optimistic shells. Dismissing the error should remove | ||
| // them entirely (see #93542) rather than only clearing the error, so navigate the user out of the now-deleted | ||
| // chat and delete it. We delete the parent chat report — deleteReport cascades from the chat down to the linked | ||
| // IOU report and the transaction thread(s). Deleting the current report here would only remove the IOU report | ||
| // (this error is dismissed from the expense report, so reportID is the IOU report ID) and leave the chat orphaned. | ||
| if (reportID && report?.errorFields?.createChat) { | ||
| const chatReportIDToDelete = report.chatReportID ?? reportID; | ||
| Navigation.goBack(undefined, {afterTransition: () => deleteReport(chatReportIDToDelete, true)}); | ||
|
Comment on lines
+271
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an expense is added to an existing chat that does not already have an IOU report, the failure builder still writes Useful? React with 👍 / 👎. |
||
| return; | ||
| } | ||
|
|
||
| if (action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && isReportActionLinked) { | ||
| navigation.setParams({reportActionID: ''}); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a failed brand-new chat, this flips the chat metadata to non-optimistic, but the created/welcome row close handler still calls
clearCreateChatError, which deletes the report only whenREPORT_METADATA.isOptimisticReportis true; once this failure merge runs, that handler only clearserrorFields.createChat. If the user closes the red error on the created row first, the optimistic chat and IOU shell are left behind, and the expense close path will no longer seereport.errorFields.createChatto clean them up.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in
ef00b98. The created-row dismiss (ReportActionItemCreated) now detects a failed brand-new chat (errorFields.createChat+ non-optimistic) and deletes the chat with the same cascade + navigate-away used by the failed-expense dismiss path, instead of falling through toclearCreateChatError(which only clears the error onceisOptimisticReportis false). So closing the red error on the created row first no longer orphans the chat/IOU shells.