Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/libs/actions/IOU/ReportWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,12 @@ function approveMoneyRequest(params: ApproveMoneyRequestFunctionParams) {
rules,
});

const parentChatKeys = new Set<string>([`${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`]);
// A vacation delegate can approve before the policy chat is ever loaded, so chatReport is missing.
// Hold skips parent-chat updates in that case; fall back to the id on the expense report so the filter still matches when the chat is loaded.
const parentChatReportID = chatReport?.reportID ?? expenseReport.chatReportID;
const parentChatKeys = new Set<string>(
parentChatReportID ? [`${ONYXKEYS.COLLECTION.REPORT}${parentChatReportID}`, `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentChatReportID}`] : [],
);
const shouldSkipParentChatUpdates = expenseReport.hasParentAccess === false;
const filterParentChatUpdates = <TUpdate extends {key: string}>(updates: TUpdate[]) =>
shouldSkipParentChatUpdates ? updates.filter((update) => !parentChatKeys.has(update.key)) : updates;
Expand Down
Loading