Skip to content
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
4 changes: 2 additions & 2 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function MoneyRequestConfirmationList({
text = translate('common.next');
}
} else if (isTypeTrackExpense) {
text = translate('iou.createExpenseWithAmount', {amount: formattedAmount});
text = translate('iou.trackExpense');
} else if (isTypeSplit && iouAmount === 0) {
text = translate('iou.splitExpense');
} else if ((receiptPath && isTypeRequest) || isDistanceRequestWithPendingRoute || isPerDiemRequest) {
Expand All @@ -438,7 +438,7 @@ function MoneyRequestConfirmationList({
text = translate('iou.submitAmount', {amount: formattedAmount});
}
} else {
const translationKey = isTypeSplit ? 'iou.splitAmount' : 'iou.createExpenseWithAmount';
const translationKey = isTypeSplit ? 'iou.splitAmount' : 'iou.submitAmount';
text = translate(translationKey, {amount: formattedAmount});
}
return [
Expand Down
1 change: 0 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ const translations = {
createExpense: 'Create expense',
trackExpense: 'Track expense',
chooseRecipient: 'Choose recipient',
createExpenseWithAmount: ({amount}: {amount: string}) => `Create ${amount} expense`,
confirmDetails: 'Confirm details',
pay: 'Pay',
cancelPayment: 'Cancel payment',
Expand Down
1 change: 0 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,6 @@ const translations = {
trackExpense: 'Seguimiento de gastos',
chooseRecipient: 'Elige destinatario',
confirmDetails: 'Confirma los detalles',
createExpenseWithAmount: ({amount}: {amount: string}) => `Crear un gasto de ${amount}`,
pay: 'Pagar',
cancelPayment: 'Cancelar el pago',
cancelPaymentConfirmation: '¿Estás seguro de que quieres cancelar este pago?',
Expand Down
98 changes: 2 additions & 96 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ type GetOptionsConfig = {
action?: IOUAction;
recentAttendees?: Attendee[];
shouldBoldTitleByDefault?: boolean;
shouldSeparateWorkspaceChat?: boolean;
shouldSeparateSelfDMChat?: boolean;
};

type GetUserToInviteConfig = {
Expand Down Expand Up @@ -140,8 +138,6 @@ type Options = {
personalDetails: ReportUtils.OptionData[];
userToInvite: ReportUtils.OptionData | null;
currentUserOption: ReportUtils.OptionData | null | undefined;
workspaceChats?: ReportUtils.OptionData[];
selfDMChat?: ReportUtils.OptionData | undefined;
};

type PreviewConfig = {showChatPreviewLine?: boolean; forcePolicyNamePreview?: boolean; showPersonalDetails?: boolean};
Expand Down Expand Up @@ -169,7 +165,7 @@ type OrderReportOptionsConfig = {
preferRecentExpenseReports?: boolean;
};

type ReportAndPersonalDetailOptions = Pick<Options, 'recentReports' | 'personalDetails' | 'workspaceChats'>;
type ReportAndPersonalDetailOptions = Pick<Options, 'recentReports' | 'personalDetails'>;

/**
* OptionsListUtils is used to build a list options passed to the OptionsList component. Several different UI views can
Expand Down Expand Up @@ -1005,23 +1001,6 @@ function orderReportOptionsWithSearch(
);
}

function orderWorkspaceOptions(options: ReportUtils.OptionData[]): ReportUtils.OptionData[] {
return lodashOrderBy(
options,
[
(option) => {
// Put default workspace on top
if (option.isPolicyExpenseChat && option.policyID === activePolicyID) {
return 0;
}

return 1;
},
],
['asc'],
);
}

function sortComparatorReportOptionByArchivedStatus(option: ReportUtils.OptionData) {
return option.private_isArchived ? 1 : 0;
}
Expand Down Expand Up @@ -1049,12 +1028,10 @@ function orderOptions(options: ReportAndPersonalDetailOptions, searchValue?: str
orderedReportOptions = orderReportOptions(options.recentReports);
}
const orderedPersonalDetailsOptions = orderPersonalDetailsOptions(options.personalDetails);
const orderedWorkspaceChats = orderWorkspaceOptions(options?.workspaceChats ?? []);

return {
recentReports: orderedReportOptions,
personalDetails: orderedPersonalDetailsOptions,
workspaceChats: orderedWorkspaceChats,
};
}

Expand Down Expand Up @@ -1163,8 +1140,6 @@ function getValidOptions(
action,
recentAttendees,
shouldBoldTitleByDefault = true,
shouldSeparateSelfDMChat = false,
shouldSeparateWorkspaceChat = false,
}: GetOptionsConfig = {},
): Options {
const topmostReportId = Navigation.getTopmostReportId() ?? '-1';
Expand Down Expand Up @@ -1240,12 +1215,6 @@ function getValidOptions(
return true;
});

let workspaceChats: ReportUtils.OptionData[] = [];

if (shouldSeparateWorkspaceChat) {
workspaceChats = allReportOptions.filter((option) => option.isOwnPolicyExpenseChat && !option.private_isArchived);
}

const allPersonalDetailsOptions = includeP2P
? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail && (includeDomainEmail || !Str.isDomainEmail(detail.login)))
: [];
Expand Down Expand Up @@ -1356,15 +1325,6 @@ function getValidOptions(
}

const currentUserOption = allPersonalDetailsOptions.find((personalDetailsOption) => personalDetailsOption.login === currentUserLogin);
let selfDMChat: ReportUtils.OptionData | undefined;

if (shouldSeparateWorkspaceChat) {
recentReportOptions = recentReportOptions.filter((option) => !option.isPolicyExpenseChat);
}
if (shouldSeparateSelfDMChat) {
selfDMChat = recentReportOptions.find((option) => option.isSelfDM);
recentReportOptions = recentReportOptions.filter((option) => !option.isSelfDM);
}

return {
personalDetails: personalDetailsOptions,
Expand All @@ -1373,8 +1333,6 @@ function getValidOptions(
// User to invite is generated by the search input of a user.
// As this function isn't concerned with any search input yet, this is null (will be set when using filterOptions).
userToInvite: null,
workspaceChats,
selfDMChat,
};
}

Expand Down Expand Up @@ -1615,7 +1573,6 @@ function formatSectionsFromSearchTerm(
filteredPersonalDetails: ReportUtils.OptionData[],
personalDetails: OnyxEntry<PersonalDetailsList> = {},
shouldGetOptionDetails = false,
filteredWorkspaceChats: ReportUtils.OptionData[] = [],
): SectionForSearchTerm {
// We show the selected participants at the top of the list when there is no search term or maximum number of participants has already been selected
// However, if there is a search term we remove the selected participants from the top of the list unless they are part of the search results
Expand All @@ -1641,9 +1598,8 @@ function formatSectionsFromSearchTerm(
const selectedParticipantsWithoutDetails = selectedOptions.filter((participant) => {
const accountID = participant.accountID ?? null;
const isPartOfSearchTerm = getPersonalDetailSearchTerms(participant).join(' ').toLowerCase().includes(cleanSearchTerm);
const isReportInRecentReports = filteredRecentReports.some((report) => report.accountID === accountID) || filteredWorkspaceChats.some((report) => report.accountID === accountID);
const isReportInRecentReports = filteredRecentReports.some((report) => report.accountID === accountID);
const isReportInPersonalDetails = filteredPersonalDetails.some((personalDetail) => personalDetail.accountID === accountID);

return isPartOfSearchTerm && !isReportInRecentReports && !isReportInPersonalDetails;
});

Expand Down Expand Up @@ -1729,23 +1685,6 @@ function filterReports(reports: ReportUtils.OptionData[], searchTerms: string[])
return filteredReports;
}

function filterWorkspaceChats(reports: ReportUtils.OptionData[], searchTerms: string[]): ReportUtils.OptionData[] {
const filteredReports = searchTerms.reduceRight(
(items, term) =>
filterArrayByMatch(items, term, (item) => {
const values: string[] = [];
if (item.text) {
values.push(item.text);
}
return uniqFast(values);
}),
// We start from all unfiltered reports:
reports,
);

return filteredReports;
}

function filterPersonalDetails(personalDetails: ReportUtils.OptionData[], searchTerms: string[]): ReportUtils.OptionData[] {
return searchTerms.reduceRight(
(items, term) =>
Expand Down Expand Up @@ -1797,34 +1736,6 @@ function filterUserToInvite(options: Omit<Options, 'userToInvite'>, searchValue:
});
}

function filterSelfDMChat(report: ReportUtils.OptionData, searchTerms: string[]): ReportUtils.OptionData | undefined {
const isMatch = searchTerms.every((term) => {
const values: string[] = [];

if (report.text) {
values.push(report.text);
}
if (report.login) {
values.push(report.login);
values.push(report.login.replace(CONST.EMAIL_SEARCH_REGEX, ''));
}
if (report.isThread) {
if (report.alternateText) {
values.push(report.alternateText);
}
} else if (!!report.isChatRoom || !!report.isPolicyExpenseChat) {
if (report.subtitle) {
values.push(report.subtitle);
}
}

// Remove duplicate values and check if the term matches any value
return uniqFast(values).some((value) => value.includes(term));
});

return isMatch ? report : undefined;
}

function filterOptions(options: Options, searchInputValue: string, config?: FilterUserToInviteConfig): Options {
const parsedPhoneNumber = PhoneNumber.parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchInputValue)));
const searchValue = parsedPhoneNumber.possible && parsedPhoneNumber.number?.e164 ? parsedPhoneNumber.number.e164 : searchInputValue.toLowerCase();
Expand All @@ -1842,17 +1753,12 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt
searchValue,
config,
);
const workspaceChats = filterWorkspaceChats(options.workspaceChats ?? [], searchTerms);

const selfDMChat = options.selfDMChat ? filterSelfDMChat(options.selfDMChat, searchTerms) : undefined;

return {
personalDetails,
recentReports,
userToInvite,
currentUserOption,
workspaceChats,
selfDMChat,
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6471,7 +6471,7 @@ function isReportNotFound(report: OnyxEntry<Report>): boolean {
/**
* Check if the report is the parent report of the currently viewed report or at least one child report has report action
*/
function shouldHideReport(report: OnyxEntry<Report>, currentReportId: string | undefined): boolean {
function shouldHideReport(report: OnyxEntry<Report>, currentReportId: string): boolean {
const currentReport = getReportOrDraftReport(currentReportId);
const parentReport = getParentReport(!isEmptyObject(currentReport) ? currentReport : undefined);
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`] ?? {};
Expand Down Expand Up @@ -6641,7 +6641,7 @@ function hasReportErrorsOtherThanFailedReceipt(report: Report, doesReportHaveVio

type ShouldReportBeInOptionListParams = {
report: OnyxEntry<Report>;
currentReportId: string | undefined;
currentReportId: string;
isInFocusMode: boolean;
betas: OnyxEntry<Beta[]>;
policies: OnyxCollection<Policy>;
Expand Down
Loading