Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent a bill split crash when a report has an undefined participant #16816

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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