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

Add keyword advanced filter for Search #46799

Conversation

289Adam289
Copy link
Contributor

@289Adam289 289Adam289 commented Aug 5, 2024

Details

Fixed Issues

$#46027
PROPOSAL:

Tests

  • visit root /search/filters

  • test keyword filter and whether navigation behaves correctly

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Same steps 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 verified the translation was requested/reviewed 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.js 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.
  • 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.

Screenshots/Videos

Android: Native
android.mp4
Android: mWeb Chrome
android_web.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios_web.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4

Copy link
Contributor

@Kicu Kicu left a comment

Choose a reason for hiding this comment

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

Looks simple and legit 👍

src/ROUTES.ts Show resolved Hide resolved
@@ -3670,6 +3670,8 @@ export default {
after: (date?: string) => `Después de ${date ?? ''}`,
},
status: 'Estado',
keyword: 'Palabra clave',
hasKeywords: 'Tiene palabras clave',
Copy link
Contributor

Choose a reason for hiding this comment

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

@luacmartins please verify

@289Adam289 289Adam289 marked this pull request as ready for review August 5, 2024 14:09
@289Adam289 289Adam289 requested a review from a team as a code owner August 5, 2024 14:09
@melvin-bot melvin-bot bot requested review from ikevin127 and removed request for a team August 5, 2024 14:10
Copy link

melvin-bot bot commented Aug 5, 2024

@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@289Adam289
Copy link
Contributor Author

@luacmartins ready for review!

@ikevin127
Copy link
Contributor

ikevin127 commented Aug 5, 2024

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • 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)
    • Any 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)
    • All JSX used for rendering exists in the render method
    • The 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
  • 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.
  • 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 have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
android.webm
Android: mWeb Chrome
android-mweb.webm
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-mweb.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov

@ikevin127
Copy link
Contributor

ikevin127 commented Aug 5, 2024

Note

The implementation only works as expected with 1 keyword, if we add 2 or more -> we get infinite loading.

⚠️ I completed the ✅ PR Reviewer Checklist, but I found one main issue with the functionality which manifests in 3 different ways which I see as possible blockers for this PR:

Note: The main issue has to do with using more than 1 keyword with different separators in between (comma, space).

  • 1. Filters label issues and infinite loading when using comma separated keywords

    Notes:

    1. This happens on all platforms.
    2. Notice the Filters labels and how there are 2 issues there:
    • each keyword appears separately as its own keyword
    • the , (comma) is seen as a separate keyword
      .
    Videos / Screenshots
    comma-separated-issue.mov
    MacOS: Web
    Screenshot 2024-08-05 at 15 25 59

  • 2. Page not found when using semicolon separated keywords

    Notes:

    1. This happens on all platforms.
      .
    Video
    semicolon-separated-issue.mov

  • 3. Infinite loading when using 2 or more space separated keywords

    Note: This happens on all platforms.

    Video
    space-separated-issue.mov

Important

  1. I noticed the Filters category Capitalizing the keywords - I reported the issue before in #46477 (comment) which was resolved by @luacmartins in #46477 (comment) as "will be fixed in a follow-up PR". Just wanted to mention this again!
  2. I think the infinite loading issues might be addressed in PR #46804 as I've reported them before in #46566 (comment) and the issue was addressed in #46566 (comment).

ℹ️ Note: I think it would be useful from a UI / UX POV to have a subtitle on the keyword input that mentions a certain separator can be used i case the user wants to have multiple keywords (cc @Expensify/design) and possible look at ways to make sure other separators / symbols won't show page not found or infinite loading when used.

@Kicu Please let me know if these are within the scope of this PR and if they should be addressed before moving forward. There are some conflicts as well. Once all of these are addressed, I will be able to 🟢 Approve.

@dubielzyk-expensify
Copy link
Contributor

Would love a video/screenshot to see how this looks with some weird string examples like:

  1. multiple words
  2. symbols characters
  3. emoji

@ikevin127
Copy link
Contributor

@dubielzyk-expensify 👋 I dropped 3 videos in the #46799 (comment) above, are you now able to see them ?

They are related to the following scenarios:

  • using comma separator
  • using semicolon separator
  • using space separator

Didn't try emojis yet.

@luacmartins
Copy link
Contributor

FYI the keyword filter is not yet supported in the backend and is throwing this error. I'm working on a PR to fix that.

@Kicu
Copy link
Contributor

Kicu commented Aug 6, 2024

  • with the newest main merged (good job @289Adam289) we should no longer be seeing multiple keyword:xxx keyword:yyy within the results page query that we display to the user. This was a bug that is now fixed.
    For every multivalue filter we want to see category:XXX,YYY keyword:1,2,3 etc.

That being said...
I believe it is worth for someone from Expensify team to describe exactly what should happen in these cases:

  • user types several words separated with space into keyword input (ex Las Vegas bill)
  • user types several words separated with comma into keyword input (ex Las,Vegas,bill)
  • user types words with mix of spaces and commas

For each of these what should be the final value of keyword filter that is being sent to backend? @luacmartins

@luacmartins
Copy link
Contributor

PR to handle keyword filter in review

@luacmartins
Copy link
Contributor

I think for now, we should treat space and commas as separators and do an OR search on each word, i.e.:

user types several words separated with space into keyword input (ex Las Vegas bill)

would search for Las OR Vegas OR bill

user types several words separated with comma into keyword input (ex Las,Vegas,bill)

would search for Las OR Vegas OR bill

user types words with mix of spaces and commas Las, Vegas, casino bill

would search for Las OR Vegas OR casino OR bill

The keyword filter is one that we'll have to refine over time, e.g. drop common words like a, of, etc, fix typos, synonyms, etc but the behavior above should be a good starting point. cc @JmillsExpensify @trjExpensify for thoughts

@shawnborton
Copy link
Contributor

From @ikevin127 's third example, when the user types in CAR RON TESLA:
CleanShot 2024-08-06 at 08 53 40@2x

The filter title spits it out as three separate keywords:
CleanShot 2024-08-06 at 08 53 26@2x

Why is that? Even if we are searching three separate words, it feels weird to the user that the string got chopped up. Can we just use keywords:CAR RON TESLA in the title?

@ikevin127
Copy link
Contributor

Can we just use keywords:CAR RON TESLA in the title?

✅ That was fixed after another PR was recently merged and is now fixed on this one as well after sync w/ main:

Screenshot 2024-08-06 at 12 57 39

In summary, to callback to the issues found (#46799 (comment)), what's needed here in order to move forward with Approval and merge:

  1. From #46799 (comment) -> we're looking at deciding what's the best way to go for the first iteration of this (to be improved in future follow-ups) and based on decision, changes will be pushed to this PR.
  2. Regarding the infinite loading, NAB I think for now (?!) as Carlos mentioned that the keyword search is not yet supported in BE so it's expected to get the infinite loading when using more than 1 keyword ? @luacmartins
  3. Which leaves the issue number (2.) Page not found when using semicolon separated keywords to be addressed.

@shawnborton
Copy link
Contributor

Hmm I still think, as a user, I would expect to see keywords:CAR RON TESLA and not keyword:CAR,RON,TESLA

@dubielzyk-expensify
Copy link
Contributor

Agree with you Shawn. Cause it's be weird if you add comma in your string, then see double commas.

@luacmartins luacmartins self-requested a review August 7, 2024 08:56
@luacmartins
Copy link
Contributor

I agree. I think we need to change the grammar to combine all filters with the same key.

@289Adam289
Copy link
Contributor Author

@ikevin127 2. Page not found using semicolon problem comes up in multiple filters. After discussing it with team and @luacmartins we agreed to handle it as a follow up. Carlos have you had a chance to create a issue for that? If not would you mind? Thanks!

@trjExpensify
Copy link
Contributor

Why is that? Even if we are searching three separate words, it feels weird to the user that the string got chopped up. Can we just use keywords:CAR RON TESLA in the title?

I agree with Shawn here. 👍

@luacmartins
Copy link
Contributor

@ikevin127 2. Page not found using semicolon problem comes up in multiple filters. After discussing it with team and @luacmartins we agreed to handle it as a follow up. Carlos have you had a chance to create a issue for that? If not would you mind? Thanks!

@289Adam289 created issue here

@luacmartins
Copy link
Contributor

@289Adam289 it seems like we still need to address some comments on how we display the filters to the user.

@Kicu Kicu mentioned this pull request Aug 8, 2024
48 tasks
@289Adam289
Copy link
Contributor Author

That's how it's displayed now
image

@shawnborton
Copy link
Contributor

Much better!

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.

The PR is looking good. There are a few issues with the parser grammar that make some of the results weird when using special characters, e.g. ,, ;, etc I think those can be addressed in a follow up though.

I'm gonna merge this PR and create a follow up issue to update the parser grammar so it handles the special character cases better.

@luacmartins luacmartins merged commit 86efffb into Expensify:main Aug 8, 2024
15 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Aug 8, 2024

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@luacmartins
Copy link
Contributor

Created issue to update parser grammar here

@Beamanator
Copy link
Contributor

FYI I believe this was deployed to prod yesterday, from this checklist - #47219

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.

9 participants