Skip to content

Suggested Search & Filter Revamp #61170

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

Open
wants to merge 99 commits into
base: main
Choose a base branch
from

Conversation

JS00001
Copy link
Contributor

@JS00001 JS00001 commented Apr 30, 2025

Explanation of Change

Implemented suggested search! See below for the expected behavior.

Fixed Issues

$ #61112
$ #61114
$ #61116
$ #61117
$ #61189

Tests

Test all variations of search. The following are supposed to be in the LHN:
Expenses, Reports, Chats: Always in LHN
'Submit' - Only in LHN when user is in a workspace
'Approve' - Only when a user is the policys 'approver', OR the user is the 'submitsTo' value for another user
'Pay' - Only when the user is a workspace admin
'Export' - Only when the user is an exporter for one of the accounting integrations

Ensure that all expected results show up, ensure that all new 'filter dropdowns' show the expected behavior and behave as expected, ensure that the new 'Filters' button works & has the expected behavior

  • Verify that no errors appear in the JS console

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I verified that similar component doesn't exist in the codebase
  • I verified that all props are defined accurately and each prop has a /** comment above it */
  • I verified that each file is named correctly
  • I verified that each component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
  • I verified that the only data being stored in component state is data necessary for rendering and nothing else
  • In component if we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
  • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
  • I verified that component internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
  • I verified that all JSX used for rendering exists in the render method
  • I verified that each component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions

Screenshots/Videos

Android: Native
iOS: Native
Screen.Recording.2025-05-09.at.11.59.29.AM.mov
iOS: mWeb Safari
Screen.Recording.2025-05-09.at.11.42.49.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2025-05-09.at.11.35.58.AM.mov

@JS00001 JS00001 self-assigned this Apr 30, 2025
@JS00001 JS00001 requested a review from luacmartins May 16, 2025 14:14
Copy link
Contributor

🚧 @JS00001 has triggered a test app build. You can view the workflow run here.

@JS00001
Copy link
Contributor Author

JS00001 commented May 16, 2025

Creating another test build, still waiting on two BE changes, so unless you have auth running with those changes, then the query for 'Pay' and 'Export' will fail

Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
Android 🤖🔄 iOS 🍎🔄
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/61170-hybrid/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/61170-hybrid/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/61170/NewExpensify.dmg https://61170.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@shawnborton
Copy link
Contributor

Feeling good on my end, thanks for addressing my feedback! I will keep testing though to try to find more for ya!

@shawnborton
Copy link
Contributor

On mobile, looks like we have a slight difference in the bottom padding of the initial date popover and then the selector UI:

Step 1 Step 2
IMG_3190 IMG_3191

@luacmartins luacmartins requested a review from getusha May 19, 2025 17:05
@JmillsExpensify
Copy link

@getusha can you please prioritize another review? We're trying to get this merged this week.

@luacmartins
Copy link
Contributor

@JS00001 we have conflicts

@getusha
Copy link
Contributor

getusha commented May 20, 2025

Minor but i think it'd be nice if we can err on invalid inputs for the date

Screenshot 2025-05-20 at 9 14 40 at night

@luacmartins
Copy link
Contributor

It'd be a nice improvement cc @Expensify/design for thoughts. That being said, I don't think we need to block this PR on that.

@dannymcclain
Copy link
Contributor

🤔 I don't know if I see that as invalid though. It's certainly silly, but what if my intention was to see all expenses before May 2nd and all expenses after May 3rd? Related: are those date inputs inclusive or exclusive?

@luacmartins
Copy link
Contributor

but what if my intention was to see all expenses before May 2nd and all expenses after May 3rd?

That'd result in no data since those filters apply with an AND operator, i.e. a single transaction's date would have to fulfill both conditions which is impossible.

@getusha
Copy link
Contributor

getusha commented May 20, 2025

In conjunction with removing the status tab bar, we’ll also remove the somewhat jarring experience of injecting status:all into every search query, even when not written by the user. This allows us to create a consistent experience among all non-required filters, such that if you filter something, we insert the corresponding query in the router to promote search syntax familiarity. If you’re filtering on all, in contrast, we insert nothing in the router.

This is from the design doc, we are still injecting status:all into every search query. i am assuming there is a reason for that @luacmartins @JS00001

@dannymcclain
Copy link
Contributor

That'd result in no data since those filters apply with an AND operator, i.e. a single transaction's date would have to fulfill both conditions which is impossible.

Oooohhhhh, I understand now. Well in that case I agree, it would be nice to let the user know they created a borked query, but I don't think it needs to block this PR.

@luacmartins
Copy link
Contributor

This is from the design doc, we are still injecting status:all into every search query. i am assuming there is a reason for that @luacmartins @JS00001

We should remove this from the frontend and just assume all as default. I also think this can be done in a follow up since that's the current behavior we have on main.

@luacmartins
Copy link
Contributor

@JS00001 we should remove the diff for Mobile-Expensify. You can run git submodule update --remote and push the changes to get rid of that diff

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

Chatted 1:1 with @JS00001 and it seems like we missed a condition for the payer filter. Jack is working on the BE fix for it

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

I also noticed that the action shown in the Export tab in the case of an approved report is Pay which is confusing. Discussing that internally with the team, but we might not block on it

Screenshot 2025-05-20 at 2 07 55 PM

))}
{shouldShowSavedSearchesMenuItemTitle && (
<View>
<Text style={[styles.sectionTitle, styles.pb1, styles.mt3]}>{translate('search.savedSearchesMenuItemTitle')}</Text>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Text style={[styles.sectionTitle, styles.pb1, styles.mt3]}>{translate('search.savedSearchesMenuItemTitle')}</Text>
<Text style={[styles.sectionTitle, styles.pb1]}>{translate('search.savedSearchesMenuItemTitle')}</Text>

I don't think we need this margin looks off:

Screenshot 2025-05-20 at 9 31 19 at night

Comment on lines +72 to +128
const listData = useMemo(() => {
const optionsList = getValidOptions(
{
reports: options.reports,
personalDetails: options.personalDetails,
},
{excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT},
);

const filteredOptionsList = filterAndOrderOptions(optionsList, cleanSearchTerm, {
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
});

const personalDetailList = filteredOptionsList.personalDetails.map((participant) => ({
...participant,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === participant.accountID),
}));

const recentReportList = filteredOptionsList.recentReports.map((report) => ({
...report,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === report.accountID),
}));

const currentUserOption = filteredOptionsList.currentUserOption
? {
...filteredOptionsList.currentUserOption,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === filteredOptionsList.currentUserOption?.accountID),
}
: null;

return {personalDetails: personalDetailList, recentReports: recentReportList, currentUserOption};
}, [cleanSearchTerm, options.personalDetails, options.reports, selectedOptions]);

const {sections, headerMessage} = useMemo(() => {
const newSections: Section[] = [
...(listData.currentUserOption ? [{title: '', data: [listData.currentUserOption], shouldShow: true}] : []),
{
title: '',
data: listData.recentReports,
shouldShow: listData.recentReports.length > 0,
},
{
title: '',
data: listData.personalDetails,
shouldShow: listData.personalDetails.length > 0,
},
];

const noResultsFound = listData.personalDetails.length === 0 && listData.recentReports.length === 0 && !listData.currentUserOption;
const message = noResultsFound ? translate('common.noResultsFound') : undefined;

return {
sections: newSections,
headerMessage: message,
};
}, [listData, translate]);
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: we could slightly simplify this

Suggested change
const listData = useMemo(() => {
const optionsList = getValidOptions(
{
reports: options.reports,
personalDetails: options.personalDetails,
},
{excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT},
);
const filteredOptionsList = filterAndOrderOptions(optionsList, cleanSearchTerm, {
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
});
const personalDetailList = filteredOptionsList.personalDetails.map((participant) => ({
...participant,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === participant.accountID),
}));
const recentReportList = filteredOptionsList.recentReports.map((report) => ({
...report,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === report.accountID),
}));
const currentUserOption = filteredOptionsList.currentUserOption
? {
...filteredOptionsList.currentUserOption,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === filteredOptionsList.currentUserOption?.accountID),
}
: null;
return {personalDetails: personalDetailList, recentReports: recentReportList, currentUserOption};
}, [cleanSearchTerm, options.personalDetails, options.reports, selectedOptions]);
const {sections, headerMessage} = useMemo(() => {
const newSections: Section[] = [
...(listData.currentUserOption ? [{title: '', data: [listData.currentUserOption], shouldShow: true}] : []),
{
title: '',
data: listData.recentReports,
shouldShow: listData.recentReports.length > 0,
},
{
title: '',
data: listData.personalDetails,
shouldShow: listData.personalDetails.length > 0,
},
];
const noResultsFound = listData.personalDetails.length === 0 && listData.recentReports.length === 0 && !listData.currentUserOption;
const message = noResultsFound ? translate('common.noResultsFound') : undefined;
return {
sections: newSections,
headerMessage: message,
};
}, [listData, translate]);
const listData = useMemo(() => {
const optionsList = getValidOptions(
{
reports: options.reports,
personalDetails: options.personalDetails,
},
{
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
selectedOptions,
includeSelectedOptions: true,
includeSelfDM: true,
},
);
const { personalDetails: filteredOptionsList, recentReports } = filterAndOrderOptions(optionsList, cleanSearchTerm, {
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
maxRecentReportsToShow: 5
});
const personalDetails = filteredOptionsList.map((participant) => ({
...participant,
isSelected: selectedOptions.some((selectedOption) => selectedOption.accountID === participant.accountID),
}));
return [...(recentReports ?? []), ...(personalDetails ?? [])];
}, [cleanSearchTerm, options.personalDetails, options.reports, selectedOptions]);
const {sections, headerMessage} = useMemo(() => {
const newSections: Section[] = [
{
title: '',
data: listData,
shouldShow: !isEmpty(listData),
},
];
const noResultsFound = isEmpty(listData);
const message = noResultsFound ? translate('common.noResultsFound') : undefined;
return {
sections: newSections,
headerMessage: message,
};
}, [listData, translate]);

import ONYXKEYS from '@src/ONYXKEYS';

function getSelectedOptionData(option: Option) {
return {...option, selected: true};
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

<ButtonWithDropdownMenu
onPress={() => null}
shouldAlwaysShowDropdownMenu
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.SMALL}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.SMALL}
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM}

Screenshot 2025-05-21 at 12 26 25 in the morning

const content: EmptySearchViewItem = useMemo(() => {
// Begin by going through all of our To-do searches, and returning their empty state
// if it exists
for (const menuItem of typeMenuItems) {
Copy link
Contributor

Choose a reason for hiding this comment

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

BUG: Not working for Reports tab

Screenshot 2025-05-20 at 10 11 37 at night

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants