Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Dec 19, 2024
1 parent 3c7be90 commit c3b7bda
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function isPersonalDetailsReady(personalDetails: OnyxEntry<PersonalDetailsList>)
* Get the participant option for a report.
*/
function getParticipantsOption(participant: ReportUtils.OptionData | Participant, personalDetails: OnyxEntry<PersonalDetailsList>): Participant {
const detail = getPersonalDetailsForAccountIDs([participant.accountID ?? -1], personalDetails)[participant.accountID ?? -1];
const detail = participant.accountID ? getPersonalDetailsForAccountIDs([participant.accountID], personalDetails)[participant.accountID] : undefined;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const login = detail?.login || participant.login || '';
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -371,7 +371,7 @@ function getParticipantsOption(participant: ReportUtils.OptionData | Participant
return {
keyForList: String(detail?.accountID),
login,
accountID: detail?.accountID ?? -1,
accountID: detail?.accountID,
text: displayName,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
firstName: (detail?.firstName || ('firstName' in participant ? participant.firstName : '')) ?? '',
Expand Down Expand Up @@ -501,11 +501,11 @@ function getIOUReportIDOfLastAction(report: OnyxEntry<Report>): string | undefin
* Get the last message text from the report directly or from other sources for special cases.
*/
function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
const reportID = report?.reportID ?? '-1';
const lastReportAction = lastVisibleReportActions[reportID] ?? null;
const reportID = report?.reportID;
const lastReportAction = reportID ? lastVisibleReportActions[reportID] : undefined;

// some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
const lastOriginalReportAction = lastReportActions[reportID] ?? null;
const lastOriginalReportAction = reportID ? lastReportActions[reportID] : undefined;
let lastMessageTextFromReport = '';

if (report?.private_isArchived) {
Expand Down Expand Up @@ -535,12 +535,12 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForMoneyRequestMessage);
} else if (ReportActionUtils.isReportPreviewAction(lastReportAction)) {
const iouReport = ReportUtils.getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find(
const lastIOUMoneyReportAction = iouReport?.reportID ? allSortedReportActions[iouReport.reportID]?.find(
(reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, key, ReportUtils.canUserPerformWriteAction(report)) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
ReportActionUtils.isMoneyRequestAction(reportAction),
);
) : undefined;
const reportPreviewMessage = ReportUtils.getReportPreviewMessage(
!isEmptyObject(iouReport) ? iouReport : null,
lastIOUMoneyReportAction,
Expand All @@ -557,7 +557,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportUtils.getReimbursementDeQueuedActionMessage(lastReportAction, report, true);
} else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportActionUtils.isPendingRemove(lastReportAction) && ReportActionUtils.isThreadParentMessage(lastReportAction, report?.reportID ?? '-1')) {
} else if (ReportActionUtils.isPendingRemove(lastReportAction) && report?.reportID && ReportActionUtils.isThreadParentMessage(lastReportAction, report.reportID)) {
lastMessageTextFromReport = Localize.translateLocal('parentReportAction.hiddenMessage');
} else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '-1', html: report?.lastMessageHtml, translationKey: report?.lastMessageTranslationKey, type: ''})) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand Down Expand Up @@ -700,7 +700,7 @@ function createOption(
hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || ReportUtils.isGroupChat(report);
subtitle = ReportUtils.getChatRoomSubtitle(report);

const lastActorDetails = personalDetailMap[report.lastActorAccountID ?? -1] ?? null;
const lastActorDetails = report.lastActorAccountID ? personalDetailMap[report.lastActorAccountID] : null;
const lastActorDisplayName = getLastActorDisplayName(lastActorDetails, hasMultipleParticipants);
const lastMessageTextFromReport = getLastMessageTextForReport(report, lastActorDetails);
let lastMessageText = lastMessageTextFromReport;
Expand Down Expand Up @@ -915,7 +915,7 @@ function createOptionList(personalDetails: OnyxEntry<PersonalDetailsList>, repor

const allPersonalDetailsOptions = Object.values(personalDetails ?? {}).map((personalDetail) => ({
item: personalDetail,
...createOption([personalDetail?.accountID ?? -1], personalDetails, reportMapForAccountIDs[personalDetail?.accountID ?? -1], {}, {showPersonalDetails: true}),
...createOption([personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID], personalDetails, reportMapForAccountIDs[personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID], {}, {showPersonalDetails: true}),
}));

return {
Expand Down

0 comments on commit c3b7bda

Please sign in to comment.