Skip to content

Commit

Permalink
Merge pull request #33174 from paultsimura/fix/33098-revert-set-merge
Browse files Browse the repository at this point in the history
fix: Revert the use of SET operation when updating Money Requests
  • Loading branch information
bondydaa authored Dec 15, 2023
2 parents 668af1c + e6557ae commit c53eca9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ function getModifiedExpenseMessage(reportAction: OnyxEntry<ReportAction>): strin
const hasModifiedCreated = reportActionOriginalMessage && 'oldCreated' in reportActionOriginalMessage && 'created' in reportActionOriginalMessage;
if (hasModifiedCreated) {
// Take only the YYYY-MM-DD value as the original date includes timestamp
let formattedOldCreated: Date | string = new Date(reportActionOriginalMessage?.oldCreated ?? 0);
let formattedOldCreated: Date | string = new Date(reportActionOriginalMessage?.oldCreated ? reportActionOriginalMessage.oldCreated : 0);
formattedOldCreated = format(formattedOldCreated, CONST.DATE.FNS_FORMAT_STRING);

return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage?.created ?? '', formattedOldCreated?.toString?.(), Localize.translateLocal('common.date'), false);
Expand Down
6 changes: 2 additions & 4 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,13 +934,11 @@ function getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, t
}

// Optimistically modify the transaction
const optimisticTransaction = onlyIncludeChangedFields ? _.pick(updatedTransaction, _.keys(transactionChanges)) : updatedTransaction;
optimisticData.push({
// We need to use SET method to save updated waypoint instead MERGE method to avoid wrong update of waypoints. More detail: https://github.com/Expensify/App/issues/30290#issuecomment-1778957070
onyxMethod: Onyx.METHOD.SET,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
...optimisticTransaction,
...updatedTransaction,
pendingFields,
isLoading: _.has(transactionChanges, 'waypoints'),
errorFields: null,
Expand Down

0 comments on commit c53eca9

Please sign in to comment.