Skip to content

Commit

Permalink
fix: chat report last visible action should not change when an old io…
Browse files Browse the repository at this point in the history
…u is updated
  • Loading branch information
cleverjam committed Apr 17, 2024
1 parent 857549e commit e40dd6e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,16 +511,15 @@ function buildOnyxDataForMoneyRequest(
newQuickAction = CONST.QUICK_ACTIONS.REQUEST_DISTANCE;
}
const existingTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingTransactionThreadReportID}`] ?? null;

if (chatReport) {
optimisticData.push({
// Use SET for new reports because it doesn't exist yet, is faster and we need the data to be available when we navigate to the chat page
onyxMethod: isNewChatReport ? Onyx.METHOD.SET : Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`,
value: {
...chatReport,
// if iouReport exist, the last visible action created time does not change.
lastVisibleActionCreated: isNewChatReport ? undefined : iouReport.lastVisibleActionCreated,
// if it is a new money request then that becomes the most recent visible action
lastVisibleActionCreated: shouldCreateNewMoneyRequestReport ? iouReport.lastVisibleActionCreated : undefined,
lastReadTime: DateUtils.getDBTime(),
lastMessageTranslationKey: '',
iouReportID: iouReport.reportID,
Expand Down Expand Up @@ -1390,6 +1389,7 @@ function getMoneyRequestInformation(
} else {
iouReport = IOUUtils.updateIOUOwnerAndTotal(iouReport, payeeAccountID, amount, currency);
}

// STEP 3: Build optimistic receipt and transaction
const receiptObject: Receipt = {};
let filename;
Expand Down

0 comments on commit e40dd6e

Please sign in to comment.