diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3c9481370744..803f94805811 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -172,8 +172,8 @@ type ReportRouteParams = { }; type ReportOfflinePendingActionAndErrors = { - addWorkspaceRoomOrChatPendingAction: PendingAction | undefined; - addWorkspaceRoomOrChatErrors: Errors | null | undefined; + reportPendingAction: PendingAction | undefined; + reportErrors: Errors | null | undefined; }; type OptimisticApprovedReportAction = Pick< @@ -4232,14 +4232,20 @@ function getOriginalReportID(reportID: string, reportAction: OnyxEntry): ReportOfflinePendingActionAndErrors { - // We are either adding a workspace room, or we're creating a chat, it isn't possible for both of these to be pending, or to have errors for the same report at the same time, so - // simply looking up the first truthy value for each case will get the relevant property if it's set. - const addWorkspaceRoomOrChatPendingAction = report?.pendingFields?.addWorkspaceRoom ?? report?.pendingFields?.createChat; - const addWorkspaceRoomOrChatErrors = getAddWorkspaceRoomOrChatReportErrors(report); - return {addWorkspaceRoomOrChatPendingAction, addWorkspaceRoomOrChatErrors}; + // It shouldn't be possible for all of these actions to be pending (or to have errors) for the same report at the same time, so just take the first that exists + const reportPendingAction = report?.pendingFields?.addWorkspaceRoom ?? report?.pendingFields?.createChat ?? report?.pendingFields?.reimbursed; + + const reportErrors = getAddWorkspaceRoomOrChatReportErrors(report); + return {reportPendingAction, reportErrors}; } function getPolicyExpenseChatReportIDByOwner(policyOwner: string): string | null { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index a7a82e642e62..6c9e206c4fc4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3136,6 +3136,10 @@ function getPayMoneyRequestParams(chatReport: OnyxTypes.Report, iouReport: OnyxT lastMessageHtml: optimisticIOUReportAction.message?.[0].html, hasOutstandingChildRequest: false, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, + pendingFields: { + preview: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + reimbursed: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, { @@ -3155,6 +3159,16 @@ function getPayMoneyRequestParams(chatReport: OnyxTypes.Report, iouReport: OnyxT }, }, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, + value: { + pendingFields: { + preview: null, + reimbursed: null, + }, + }, + }, ]; const failureData: OnyxUpdate[] = [ diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index bfe27910c943..1663dd5ac1e0 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -258,7 +258,7 @@ function ReportScreen({ } const reportID = getReportID(route); - const {addWorkspaceRoomOrChatPendingAction, addWorkspaceRoomOrChatErrors} = ReportUtils.getReportOfflinePendingActionAndErrors(report); + const {reportPendingAction, reportErrors} = ReportUtils.getReportOfflinePendingActionAndErrors(report); const screenWrapperStyle = [styles.appContent, styles.flex1, {marginTop: viewportOffsetTop}]; const isEmptyChat = useMemo(() => _.isEmpty(reportActions), [reportActions]); // There are no reportActions at all to display and we are still in the process of loading the next set of actions. @@ -521,8 +521,8 @@ function ReportScreen({ shouldShowLink={false} > @@ -572,7 +572,7 @@ function ReportScreen({ {isReportReadyForDisplay ? (