diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 506bfd06936d..5310bf6e13b3 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3230,10 +3230,10 @@ function updateMoneyRequestDistance({ if (transactionBackup) { const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; - // We need to have all the keys of the original waypoint in the failure data for onyx merge to properly reset - // waypoints keys that do not exist in the waypoint of the reverting failure data. For instance, if a waypoint had - // three keys and the waypoint we we want to revert to has 2 keys then the third key that doesn't exist in the failureData - // waypoint should be explicitly reset otherwise onyx merge will leave it intact. + // We need to include all keys of the optimisticData's waypoints in the failureData for onyx merge to properly reset + // waypoint keys that do not exist in the failureData's waypoints. For instance, if the optimisticData waypoints had + // three keys and the failureData waypoint had only 2 keys then the third key that doesn't exist in the failureData + // waypoints should be explicitly reset otherwise onyx merge will leave it intact. const allWaypointKeys = [...new Set([...Object.keys(transactionBackup.comment?.waypoints ?? {}), ...Object.keys(transaction?.comment?.waypoints ?? {})])]; const onyxWaypoints = allWaypointKeys.reduce((acc: NullishDeep, key) => { acc[key] = transactionBackup.comment?.waypoints?.[key] ? {...transactionBackup.comment?.waypoints?.[key]} : null;