Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -4232,14 +4232,20 @@ function getOriginalReportID(reportID: string, reportAction: OnyxEntry<ReportAct
}

/**
* Return the pendingAction and the errors we have when creating a chat or a workspace room offline
* Return the pendingAction and the errors resulting from either
*
* - creating a workspace room
* - starting a chat
* - paying the money request
*
* while being offline
*/
function getReportOfflinePendingActionAndErrors(report: OnyxEntry<Report>): 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;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #76323, we shouldn't grey out the entire report when reimbursed is pending update


const reportErrors = getAddWorkspaceRoomOrChatReportErrors(report);
return {reportPendingAction, reportErrors};
}

function getPolicyExpenseChatReportIDByOwner(policyOwner: string): string | null {
Expand Down
14 changes: 14 additions & 0 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
{
Expand All @@ -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[] = [
Expand Down
8 changes: 4 additions & 4 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -521,8 +521,8 @@ function ReportScreen({
shouldShowLink={false}
>
<OfflineWithFeedback
pendingAction={addWorkspaceRoomOrChatPendingAction}
errors={addWorkspaceRoomOrChatErrors}
pendingAction={reportPendingAction}
errors={reportErrors}
shouldShowErrorMessages={false}
needsOffscreenAlphaCompositing
>
Expand Down Expand Up @@ -572,7 +572,7 @@ function ReportScreen({
{isReportReadyForDisplay ? (
<ReportFooter
report={report}
pendingAction={addWorkspaceRoomOrChatPendingAction}
pendingAction={reportPendingAction}
isComposerFullSize={isComposerFullSize}
listHeight={listHeight}
isEmptyChat={isEmptyChat}
Expand Down