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

Minimal server search / enable improved focus mode #27819

Merged
merged 38 commits into from
Oct 13, 2023

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Sep 20, 2023

Details

Adds server assisted searching to the "Search" page.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/318005
$ https://github.com/Expensify/Expensify/issues/318006

Tests

The tests here are primarily designed to prove that we can return reports that hit on the following search queries from Auth...

  • A participant login (for now, we are not going to be able to search by display name)
  • A policy name (it should return any newdot accessible reports on the policy)
  • Report owner email (e.g. a workspace chat)
  1. Sign into NewDot
  2. Create a workspace
  3. Rename the workspace to "Business Name"
  4. Add 2 employees
  5. Navigate to the Search page
  6. Enter the search term "concierge"
  7. Verify there is a loading spinner that appears inside the text input and then is removed later once the API command finishes
  8. Verify via the Chrome DevTools that the Onyx data response for the SearchForReports command returns the Concierge report
2023-09-20_12-29-22
  1. Enter the search term "test"
  2. Verify that the 3 workspace chats and 2 policy rooms are returned by SearchForReports
  3. Enter a specific login for one of the employees added
  4. Verify the "#announce" report and the workspace chat that they own are returned in the response
2023-09-20_13-01-01
  1. Sign in as one of the employees and set the firstName field of the personal details to "Bob"
  2. Sign back in as the workspace admin
  3. Navigate to Search again
  4. Enter "Bob" into the search field
  5. Verify the same result as step 14.

Test that switching from "#focus" to "Most recent" will restore chats

  1. Switch to focus mode
  2. Sign out
  3. Sign in
  4. Verify that only a limited number of chats are displayed
  5. Set up two other devices and sign in with the same account
  6. Leave one device open and the other backgrounded (mobile)
  7. Switch to "Most recent" mode on the main account from "focus" mode
  8. And verify that...
  9. All the devices switched modes and have all the chats
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline while in the Search view
  2. Verify that a message appears indicating that search results will be limited
2023-09-20_12-40-57

QA Steps

  1. Same as tests

(probably Internal so that we can help verify)

  • 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 / Chrome
    • iOS / native
    • iOS / 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 approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • 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 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
    • 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)
    • 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(themeColors.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 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 author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

2023-10-04_12-44-33

Mobile Web - Chrome

2023-10-04_13-07-44

Mobile Web - Safari

2023-10-04_13-00-35

Desktop

2023-10-04_13-03-40

iOS

2023-10-04_12-42-43

Android

2023-10-04_13-01-47

@marcaaron marcaaron self-assigned this Sep 20, 2023
@marcaaron marcaaron added the InternalQA This pull request required internal QA label Sep 20, 2023
@marcaaron marcaaron changed the title Minimal server search [HOLD Auth / Web-E] Minimal server search Sep 21, 2023
@marcaaron marcaaron changed the title [HOLD Auth / Web-E] Minimal server search [HOLD Auth / Web-E] Minimal server search / enable improved focus mode Sep 28, 2023
@marcaaron marcaaron changed the title [HOLD Auth / Web-E] Minimal server search / enable improved focus mode [HOLD Web-E] Minimal server search / enable improved focus mode Sep 28, 2023
@marcaaron
Copy link
Contributor Author

marcaaron commented Sep 28, 2023

@roryabraham @aldo-expensify taking this out of draft to start some reviews...

Still waiting on:

  • Correct español translation
  • Staging CPs for the 2 web PRs to opt into the focus mode and SearchForReports API command

It's been testing well for me locally more or less.

One thing that was missed is that when we switch the priority mode from "#focus" to "Most recent" we need to return all the chats so that view can be populated. This situation is possible:

  1. Be signed into two devices with "#focus" mode
  2. Put one into the background
  3. Update the priority mode to "Most recent" on one device
  4. Open the other device up again
  5. Other device will be in "Most recent" mode, but still only have the "#focus" mode chats

The obvious solution seems to be to just get and send all the chats via Pusher when the priority mode changes, but I am not actually sure if it would be a problem to send these large payloads via Pusher... will think more about it. I think it's not much of a blocker to do some testing on an Ad Hoc build. But maybe we want to hold merging this until there's a solution for that.

My plan after the review is done is to do an Ad Hoc build - but not merge this PR until:

  • We have a few guides test to see if things are improved for them
  • Things are stable and tested
  • Design kinks related to search are ironed
  • The switch between "#focus" and "Most recent" is a bit more polish

@marcaaron marcaaron marked this pull request as ready for review September 28, 2023 12:02
@marcaaron marcaaron requested a review from a team as a code owner September 28, 2023 12:02
@melvin-bot melvin-bot bot requested review from hoangzinh and removed request for a team September 28, 2023 12:02
@melvin-bot
Copy link

melvin-bot bot commented Sep 28, 2023

@hoangzinh 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]

@marcaaron
Copy link
Contributor Author

as we go, I will also add some more manual test steps for checking to see that the correct focus mode chats will come back when signing in.

@sakluger
Copy link
Contributor

Looks like https://github.com/Expensify/Web-Expensify/pull/38916 is now on staging 🎉 . Does that mean this PR is now off hold?

src/components/OptionsSelector/BaseOptionsSelector.js Outdated Show resolved Hide resolved
src/pages/NewChatPage.js Outdated Show resolved Hide resolved
src/pages/SearchPage.js Outdated Show resolved Hide resolved
src/pages/SearchPage.js Outdated Show resolved Hide resolved
src/libs/actions/Report.js Outdated Show resolved Hide resolved
@aldo-expensify
Copy link
Contributor

@marcaaron no need to keep holding on https://github.com/Expensify/Web-Expensify/pull/38916, right? since it hit staging already

@melvin-bot
Copy link

melvin-bot bot commented Oct 7, 2023

🎯 @hoangzinh, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #29046.

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

Code looks good, but we're missing a few new proptypes, no?

src/components/OptionsList/BaseOptionsList.js Outdated Show resolved Hide resolved
src/pages/NewChatPage.js Show resolved Hide resolved
src/pages/SearchPage.js Show resolved Hide resolved
@marcaaron
Copy link
Contributor Author

@Beamanator thanks for the review ❤️ ! Made the changes 🙇

Beamanator
Beamanator previously approved these changes Oct 11, 2023
Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

Looks great and is working well here! But there's conflicts :'(

And I wonder if @roryabraham wants to review before I merge? Aldo is OOO i beleive

@marcaaron
Copy link
Contributor Author

I think they are both OOO

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Not officially requesting changes because I don't want to delay this while I'm OOO, but I had a few comments that maybe should be addressed. Don't think anything will blow up if they're not addressed

src/libs/actions/App.js Outdated Show resolved Hide resolved
/**
* @param {string} searchInput
*/
function searchInServer(searchInput) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB

Suggested change
function searchInServer(searchInput) {
function searchForReportsInServer(searchInput) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's already Report.searchInServer() so you would have Report.searchForReportInServer() 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

true that reads a bit funky

src/pages/SearchPage.js Show resolved Hide resolved
initWithStoredValues: false,
},
network: {
key: ONYXKEYS.NETWORK,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use the withNetwork HOC instead of withOnyx. Also ONYXKEYS.NETWORK should typically be initWithStoredValues: false, because we don't have any reason to think that the persisted value for isOffline should be accurate the next time the user opens the app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating to withNetwork since it will reduce a subscription.

But there are so many places where we do not consider this...

we don't have any reason to think that the persisted value for isOffline should be accurate the next time the user opens the app

nothing super bad happens AFAICT

marcaaron and others added 3 commits October 12, 2023 09:02
Co-authored-by: Rory Abraham <47436092+roryabraham@users.noreply.github.com>
@marcaaron
Copy link
Contributor Author

Updated!

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

LGTM!

@Beamanator Beamanator merged commit 1201077 into main Oct 13, 2023
15 checks passed
@Beamanator Beamanator deleted the marcaaron-minimalSearch branch October 13, 2023 06:27
@OSBotify
Copy link
Contributor

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.84-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀

platform result
🤖 android 🤖 skipped 🚫
🖥 desktop 🖥 skipped 🚫
🍎 iOS 🍎 skipped 🚫
🕸 web 🕸 skipped 🚫

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.85-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.3.85-4 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
InternalQA This pull request required internal QA Ready To Build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants