Skip to content

Commit

Permalink
Merge pull request #16816 from Expensify/neil-split-crash
Browse files Browse the repository at this point in the history
Prevent a bill split crash when a report has an undefined participant
  • Loading branch information
jasperhuangg authored Mar 31, 2023
2 parents bbcf7ce + 6a874bc commit b6f7eca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
32 changes: 18 additions & 14 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,26 @@ function getPersonalDetailsForLogins(logins, personalDetails) {
if (!personalDetails) {
return personalDetailsForLogins;
}
_.each(logins, (login) => {
let personalDetail = personalDetails[login];
if (!personalDetail) {
personalDetail = {
login,
displayName: Str.removeSMSDomain(login),
avatar: ReportUtils.getDefaultAvatar(login),
};
}
_.chain(logins)

// Somehow it's possible for the logins coming from report.participants to contain undefined values so we use compact to remove them.
.compact()
.each((login) => {
let personalDetail = personalDetails[login];
if (!personalDetail) {
personalDetail = {
login,
displayName: Str.removeSMSDomain(login),
avatar: ReportUtils.getDefaultAvatar(login),
};
}

if (login === CONST.EMAIL.CONCIERGE) {
personalDetail.avatar = CONST.CONCIERGE_ICON_URL;
}
if (login === CONST.EMAIL.CONCIERGE) {
personalDetail.avatar = CONST.CONCIERGE_ICON_URL;
}

personalDetailsForLogins[login] = personalDetail;
});
personalDetailsForLogins[login] = personalDetail;
});
return personalDetailsForLogins;
}

Expand Down
8 changes: 7 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ function getChatType(report) {
* @returns {string}
*/
function getReportParticipantsTitle(logins) {
return _.map(logins, login => Str.removeSMSDomain(login)).join(', ');
return _.chain(logins)

// Somehow it's possible for the logins coming from report.participants to contain undefined values so we use compact to remove them.
.compact()
.map(login => Str.removeSMSDomain(login))
.value()
.join(', ');
}

/**
Expand Down

0 comments on commit b6f7eca

Please sign in to comment.