From c75394acffc054cdcd03880babd6b98b1741de01 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 11 Oct 2023 15:27:32 +0530 Subject: [PATCH 1/4] no optimisticID creation for existing user --- src/libs/actions/IOU.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index d5676672dd33..5fefe205dbd9 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1055,7 +1055,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco let oneOnOneChatReport; let isNewOneOnOneChatReport = false; let shouldCreateOptimisticPersonalDetails = false; - + const personalDetailExists = _.has(allPersonalDetails, accountID); // If this is a split between two people only and the function // wasn't provided with an existing group chat report id // or, if the split is being made from the workspace chat, then the oneOnOneChatReport is the same as the splitChatReport @@ -1063,11 +1063,11 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco // entering code that creates optimistic personal details if ((!hasMultipleParticipants && !existingSplitChatReportID) || isOwnPolicyExpenseChat) { oneOnOneChatReport = splitChatReport; - shouldCreateOptimisticPersonalDetails = !existingSplitChatReport; + shouldCreateOptimisticPersonalDetails = !existingSplitChatReport && !personalDetailExists; } else { const existingChatReport = ReportUtils.getChatByParticipants([accountID]); isNewOneOnOneChatReport = !existingChatReport; - shouldCreateOptimisticPersonalDetails = isNewOneOnOneChatReport; + shouldCreateOptimisticPersonalDetails = isNewOneOnOneChatReport && !personalDetailExists; oneOnOneChatReport = existingChatReport || ReportUtils.buildOptimisticChatReport([accountID]); } From a3981c33f5ba233350b51e5479e61bee136de472 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 11 Oct 2023 16:06:26 +0530 Subject: [PATCH 2/4] use lodashHas instead of _.has --- src/libs/actions/IOU.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 5fefe205dbd9..46b76f746d58 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1,6 +1,7 @@ import Onyx from 'react-native-onyx'; import _ from 'underscore'; import lodashGet from 'lodash/get'; +import lodashHas from 'lodash/has'; import Str from 'expensify-common/lib/str'; import {format} from 'date-fns'; import CONST from '../../CONST'; @@ -1055,7 +1056,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco let oneOnOneChatReport; let isNewOneOnOneChatReport = false; let shouldCreateOptimisticPersonalDetails = false; - const personalDetailExists = _.has(allPersonalDetails, accountID); + const personalDetailExists = lodashHas(allPersonalDetails, accountID); // If this is a split between two people only and the function // wasn't provided with an existing group chat report id // or, if the split is being made from the workspace chat, then the oneOnOneChatReport is the same as the splitChatReport From 869ee9c4f4d8a81eed19c8417804478550504bc8 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 11 Oct 2023 16:30:27 +0530 Subject: [PATCH 3/4] add empty line before comment --- src/libs/actions/IOU.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 46b76f746d58..381473c42084 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1057,6 +1057,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco let isNewOneOnOneChatReport = false; let shouldCreateOptimisticPersonalDetails = false; const personalDetailExists = lodashHas(allPersonalDetails, accountID); + // If this is a split between two people only and the function // wasn't provided with an existing group chat report id // or, if the split is being made from the workspace chat, then the oneOnOneChatReport is the same as the splitChatReport From 55bc86953611eea8f7db98c639c04f9cbf6fdc27 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 11 Oct 2023 16:44:17 +0530 Subject: [PATCH 4/4] sync with prettier --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 381473c42084..4863c9a3561c 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1057,7 +1057,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco let isNewOneOnOneChatReport = false; let shouldCreateOptimisticPersonalDetails = false; const personalDetailExists = lodashHas(allPersonalDetails, accountID); - + // If this is a split between two people only and the function // wasn't provided with an existing group chat report id // or, if the split is being made from the workspace chat, then the oneOnOneChatReport is the same as the splitChatReport