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

[Search v1] Add bulk actions #44385

Merged
merged 30 commits into from
Jul 2, 2024

Conversation

WojtekBoman
Copy link
Contributor

@WojtekBoman WojtekBoman commented Jun 25, 2024

Details

This PR adds support for bulk actions in the Search tab.

Screen.Recording.2024-07-01.at.17.33.55.mov

Fixed Issues

$ #39887
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console
  1. Launch the app.
  2. Open the Search tab.
  3. Verify if selecting checkboxes works correctly for TransactionListItems and ReportItems.

Offline tests

QA Steps

  • 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

This functionality is only supported on wide screen.

MacOS: Chrome / Safari
Screen.Recording.2024-07-01.at.17.33.55.mov
MacOS: Desktop
Screen.Recording.2024-07-02.at.17.04.12.mov

@luacmartins luacmartins self-requested a review June 25, 2024 20:10
@luacmartins
Copy link
Contributor

@WojtekBoman FYI the PR for DeleteMoneyRequestOnSearch was merged today and should be available in production soon so you can start testing that case.

@trjExpensify
Copy link
Contributor

👋 @WojtekBoman how are you getting on here? Just a heads up that the basic CSV export project is a critical deliverable for GBTA (conference) on July 22nd. As the work to add the selection checkboxes to the Search page has begun with this PR, it's now effectively a blocker to getting that project complete before the conference.

We're starting on imp today, and @rlinoz will work on the backend in the meantime, but it would be good to clear this dependency ASAP.

@luacmartins
Copy link
Contributor

@WojtekBoman given this is a blocker and the hold/unhold commands are not ready yet. Let's implement only Delete for now and we add hold/unhold as a follow up

@trjExpensify
Copy link
Contributor

Great idea!

@WojtekBoman WojtekBoman marked this pull request as ready for review July 1, 2024 15:37
@WojtekBoman WojtekBoman requested a review from a team as a code owner July 1, 2024 15:37
@melvin-bot melvin-bot bot removed the request for review from a team July 1, 2024 15:37
Copy link

melvin-bot bot commented Jul 1, 2024

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

@melvin-bot melvin-bot bot requested a review from DylanDylann July 1, 2024 15:37
@WojtekBoman
Copy link
Contributor Author

Bug: No confirm modal is shown when choosing the delete option on the search page.

On the transaction page, we display this confirm modal:

Screenshot 2024-07-02 at 2 23 06 AM

Not sure if this is considered a bug or expected:

  1. Login with an account that has a lot of expenses
  2. Open search page
  3. Click on the Select All checkbox
  4. Scroll down to load more expenses
  5. Notice that the loaded expenses are not selected

Screen.Recording.2024-07-02.at.1.47.08.AM.mov

@luacmartins I don't know if we should address these 2 cases. If so, could we create followups and merge this PR? I'll be OOO from 03.07 to 08.07 and wouldn't like to hold CSV export.

@melvin-bot melvin-bot bot requested a review from luacmartins July 2, 2024 15:16
@luacmartins
Copy link
Contributor

@luacmartins I don't know if we should address these 2 cases. If so, could we create followups and merge this PR? I'll be OOO from 03.07 to 08.07 and wouldn't like to hold CSV export.

Yea, I think addressing them as follow ups is fine. That being said, I'm unsure if we need to address them too. I think yes for the delete confirm modal, but no for the scroll checkbox issue.

luacmartins
luacmartins previously approved these changes Jul 2, 2024
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.

Left a few comments. I'll get this PR merged since none of them are blockers. Let's address them in a follow up though!

value: CONST.SEARCH.BULK_ACTION_TYPES.HOLD,
onSelected: () => {
clearSelectedItems?.();
SearchActions.holdMoneyRequestOnSearch(hash, itemsToHold, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll still need to redirect the user to the reason page. Maybe that's something that @Kicu can address in his PR?

return (
<>
<SearchPageHeader
selectedItems={{}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just add a default to the component prop instead of passing this empty object? This just looks odd.

return (
<>
<SearchPageHeader
selectedItems={{}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@luacmartins
Copy link
Contributor

@WojtekBoman we have conflicts

@WojtekBoman
Copy link
Contributor Author

@WojtekBoman we have conflicts

Solved :)

@luacmartins luacmartins merged commit fe880cb into Expensify:main Jul 2, 2024
15 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jul 2, 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.

@Kicu
Copy link
Contributor

Kicu commented Jul 3, 2024

I will go over this PR and address any followups required in a separate PR

@Kicu
Copy link
Contributor

Kicu commented Jul 3, 2024

@luacmartins about this:

We'll still need to redirect the user to the reason page.

Here is a small possibile future issue that I would like to discuss. Right now when displaying the Reason modal for 1 hold, we pass the id from Search view to RHP via a param. The URL on my PR looks like this .../search/all/hold/3802232314780767339/1656485478.

However if we also want to display the same modal for bulk actions, then there is no limit to the amount of transactions a user can check. If we continue to pass them, we would have to change url to something like: .../search/all/hold/?transactionIds=12345,54321,... - or something similar. That is we would have to encode a list of x amount of transaction ids. It feels a bit risky because in theory a user could select 100+ or more transactions and we could hit the URL length limit.

Any other way of handling this would have to involve onyx I guess, where we save the selection in onyx, navigate to RHP hold reason page and then read from onyx.
Or is there any other method of passing such context data to view that I'm missing? CC @adamgrzybowski what do you think about this?

I would like for this RHP screen for Hold to work the same whether it's 1 transaction or bulk transactions, so I think I would create a new PR for this tomorrow, once we agree on a solution.

@OSBotify
Copy link
Contributor

OSBotify commented Jul 3, 2024

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.4-0 🚀

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

@luacmartins
Copy link
Contributor

@Kicu that's an issue and I agree that we should use the same page for all these actions. I think we could either go the Onyx route or React context to keep this in state since it doesn't really need to be persisted. Maybe creating a hook for it would be good, e.g. useSelectedItems or something like that.

@OSBotify
Copy link
Contributor

OSBotify commented Jul 4, 2024

🚀 Cherry-picked to staging by https://github.com/tgolen in version: 9.0.4-5 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.0.5-13 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.6-8 🚀

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

showItemHeaderOnNarrowLayout={false}
containerStyle={styles.mt3}
isChildListItem
isDisabled={!!isDisabled}
canSelectMultiple={!!canSelectMultiple}
isButtonSelected={item.isSelected}
Copy link
Contributor

Choose a reason for hiding this comment

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

there was a design issue Individually selected expense rows in grouped reports don't have a background color applied to them, we fixed it #45384 by checking transaction.isSelected instead of item.isSelected

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