Skip to content

Commit

Permalink
Merge pull request #28426 from dukenv0307/fix/28028
Browse files Browse the repository at this point in the history
Remove optimistic personal detail after requesting money
  • Loading branch information
madmax330 authored Oct 4, 2023
2 parents a7f070a + 47d2ece commit d9a603d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
isPolicyExpenseChat: false,
isExpenseReport: false,
policyID: null,
isOptimisticPersonalDetail: false,
};

const personalDetailMap = getPersonalDetailsForAccountIDs(accountIDs, personalDetails);
Expand All @@ -476,6 +477,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
let reportName;

result.participantsList = personalDetailList;
result.isOptimisticPersonalDetail = personalDetail.isOptimisticPersonalDetail;

if (report) {
result.isChatRoom = ReportUtils.isChatRoom(report);
Expand Down Expand Up @@ -1166,6 +1168,7 @@ function getOptions(
if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames, isChatRoom)) {
return;
}

personalDetailsOptions.push(personalDetailOption);
});
}
Expand All @@ -1177,7 +1180,10 @@ function getOptions(

let userToInvite = null;
const noOptions = recentReportOptions.length + personalDetailsOptions.length === 0 && !currentUserOption;
const noOptionsMatchExactly = !_.find(personalDetailsOptions.concat(recentReportOptions), (option) => option.login === addSMSDomainIfPhoneNumber(searchValue).toLowerCase());
const noOptionsMatchExactly = !_.find(
personalDetailsOptions.concat(recentReportOptions),
(option) => option.login === addSMSDomainIfPhoneNumber(searchValue).toLowerCase() || option.login === searchValue.toLowerCase(),
);

if (
searchValue &&
Expand Down Expand Up @@ -1246,7 +1252,7 @@ function getOptions(
}

return {
personalDetails: personalDetailsOptions,
personalDetails: _.filter(personalDetailsOptions, (personalDetailsOption) => !personalDetailsOption.isOptimisticPersonalDetail),
recentReports: recentReportOptions,
userToInvite: canInviteUser ? userToInvite : null,
currentUserOption,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ function getMoneyRequestInformation(
avatar: UserUtils.getDefaultAvatarURL(payerAccountID),
displayName: LocalePhoneNumber.formatPhoneNumber(participant.displayName || payerEmail),
login: participant.login,
isOptimisticPersonalDetail: true,
},
}
: undefined;
Expand Down Expand Up @@ -1117,6 +1118,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
avatar: UserUtils.getDefaultAvatarURL(accountID),
displayName: LocalePhoneNumber.formatPhoneNumber(participant.displayName || email),
login: participant.login,
isOptimisticPersonalDetail: true,
},
}
: undefined;
Expand Down

0 comments on commit d9a603d

Please sign in to comment.