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

Bold all title and don't show last message in search "In" filter page #49835

Merged
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/Search/SearchFiltersChatsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen
const selectedOptions = useMemo<OptionData[]>(() => {
return selectedReportIDs.map((id) => {
const report = getSelectedOptionData(OptionsListUtils.createOptionFromReport({...reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reportID: id}, personalDetails));
const alternateText = OptionsListUtils.getAlternateText(report, {showChatPreviewLine: true});
const alternateText = OptionsListUtils.getAlternateText(report, {});
return {...report, alternateText};
});
}, [personalDetails, reports, selectedReportIDs]);
Expand All @@ -65,7 +65,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen
if (!areOptionsInitialized || !isScreenTransitionEnd) {
return defaultListOptions;
}
return OptionsListUtils.getSearchOptions(options);
return OptionsListUtils.getSearchOptions(options, '', undefined, false);
}, [areOptionsInitialized, isScreenTransitionEnd, options]);

const chatOptions = useMemo(() => {
Expand Down
22 changes: 16 additions & 6 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,15 @@ function getAlternateText(option: ReportUtils.OptionData, {showChatPreviewLine =
const report = ReportUtils.getReportOrDraftReport(option.reportID);
const isAdminRoom = ReportUtils.isAdminRoom(report);
const isAnnounceRoom = ReportUtils.isAnnounceRoom(report);
const isGroupChat = ReportUtils.isGroupChat(report);
const isExpenseThread = ReportUtils.isMoneyRequest(report);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just returning whether the report is a money request report, not if it is a thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment above clarified this as well.


if (!!option.isThread || !!option.isMoneyRequestReport) {
return option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet');
if (isExpenseThread || option.isMoneyRequestReport) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isExpenseThread and option.isMoneyRequestReport are equivalent, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are different.

isMoneyRequestReport checks for expense/IOU report.

result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);

App/src/libs/ReportUtils.ts

Lines 1611 to 1614 in 05ca35c

function isMoneyRequestReport(reportOrID: OnyxInputOrEntry<Report> | string): boolean {
const report = typeof reportOrID === 'string' ? ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`] ?? null : reportOrID;
return isIOUReport(report) || isExpenseReport(report);
}

isExpenseThread checks if it's the transaction thread.

App/src/libs/ReportUtils.ts

Lines 1603 to 1606 in 05ca35c

function isMoneyRequest(reportOrID: OnyxEntry<Report> | string): boolean {
const report = typeof reportOrID === 'string' ? ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`] ?? null : reportOrID;
return isIOURequest(report) || isExpenseRequest(report);
}

App/src/libs/ReportUtils.ts

Lines 1566 to 1586 in 05ca35c

function isExpenseRequest(report: OnyxInputOrEntry<Report>): report is Thread {
if (isThread(report)) {
const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID];
const parentReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
return isExpenseReport(parentReport) && !isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction);
}
return false;
}
/**
* An IOU Request is a thread where the parent report is an IOU Report and
* the parentReportAction is a transaction.
*/
function isIOURequest(report: OnyxInputOrEntry<Report>): boolean {
if (isThread(report)) {
const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID];
const parentReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
return isIOUReport(parentReport) && !isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction);
}
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, those method names are definitely misleading. Thanks for clarifying though

return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'iou.expense');
}

if (option.isThread) {
return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'threads.thread');
}

if (option.isChatRoom && !isAdminRoom && !isAnnounceRoom) {
Expand All @@ -546,7 +552,11 @@ function getAlternateText(option: ReportUtils.OptionData, {showChatPreviewLine =
}

if (option.isTaskReport) {
return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet');
return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'task.task');
}

if (isGroupChat) {
return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'common.group');
}

return showChatPreviewLine && option.lastMessageText
Expand Down Expand Up @@ -2084,7 +2094,7 @@ function getOptions(
/**
* Build the options for the Search view
*/
function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = []): Options {
function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = [], isUsedInChatFinder = true): Options {
Timing.start(CONST.TIMING.LOAD_SEARCH_OPTIONS);
Performance.markStart(CONST.TIMING.LOAD_SEARCH_OPTIONS);
const optionList = getOptions(options, {
Expand All @@ -2094,15 +2104,15 @@ function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] =
includeMultipleParticipantReports: true,
maxRecentReportsToShow: 0, // Unlimited
sortByReportTypeInSearch: true,
showChatPreviewLine: true,
showChatPreviewLine: isUsedInChatFinder,
includeP2P: true,
forcePolicyNamePreview: true,
includeOwnedWorkspaceChats: true,
includeThreads: true,
includeMoneyRequests: true,
includeTasks: true,
includeSelfDM: true,
shouldBoldTitleByDefault: false,
shouldBoldTitleByDefault: !isUsedInChatFinder,
});
Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS);
Performance.markEnd(CONST.TIMING.LOAD_SEARCH_OPTIONS);
Expand Down
Loading