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

[$250] Track > Categorize it flow - Unable to search for workspace chats if the reports are not visited previously #47854

Open
6 tasks done
lanitochka17 opened this issue Aug 22, 2024 · 61 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 22, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.23-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a few workspaces
  3. Go to self DM
  4. Send a message
  5. Log out and log it
  6. Do not open any workspace chat and go to self DM
  7. Click + > Track expense > Manual
  8. Submit a track manual expense
  9. Click Categorize it
  10. Search for other existing workspace chats that do not show up in the list
  11. Note that the other existing workspace chats do not return in the search result
  12. Open all the workspace chats
  13. Repeat Step 9 and 10
  14. Note that workspace chats are only searchable after the workspace chats are visited

Expected Result:

In Step 11, user should be able to search for other existing workspace chats

Actual Result:

In Step 11, user is unable to search for other existing workspace chats
The search only returns results after the workspace chats are visited (Step 14)

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6579117_1724318988637.20240822_172134.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01570efd314fb561ac
  • Upwork Job ID: 1828744919457771906
  • Last Price Increase: 2024-09-18
  • Automatic offers:
    • dukenv0307 | Reviewer | 104043144
    • jaydamani | Contributor | 104043145
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 22, 2024
Copy link

melvin-bot bot commented Aug 22, 2024

Triggered auto assignment to @dylanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@lanitochka17
Copy link
Author

@dylanexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@jaydamani
Copy link
Contributor

jaydamani commented Aug 22, 2024

Edited by proposal-police: This proposal was edited at 2023-10-04T22:06:00Z.

Proposal

Please re-state the problem that we are trying to solve in this issue.

When categorizing a tracked expense, only previously visited workspaces are shown

What is the root cause of that problem?

When categorizing expense, we do an additional check to see if the workspace has categories enabled by checking if policyCategory for that workspace has at least 1 category enabled but currently, when you logout and then login, policyCategory is not being loaded for workspaces with categories enabled. It is only loaded for workspace where the category feature and all categories are disabled. This data is supposed to come from OpenApp request. When you open a report, then also policyCategory is populated which is why we start to see the workspace after it is opened once

const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${reportOption.policyID}`] ?? {};

let allPolicyCategories: OnyxCollection<PolicyCategories> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_CATEGORIES,
waitForCollectionCallback: true,
callback: (val) => (allPolicyCategories = val),
});

image

What changes do you think we should make in order to solve the problem?

Update front end to check isCategoryEnabled in the policy then update here to call an API and load categories of the selected policy.
A new API will be needed from backend to load all categories of a given workspace.

What alternative solutions did you explore? (Optional)

Considering that policyCategory loads for workspace without categories but not for workspaces with categories, this likely requires a fix from backend most likely for OpenApp.

@klajdipaja
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

When submitting an expense and attempting to "Categorize" it into a workspace the "Categorize" modal does not show any options in the recent tab unless the user has opened each one of them in the current session.

What is the root cause of that problem?

The root cause of the problem is in OptionsListUtils.ts#getOptions where we filter out the reports that should be shown in the list. Currently the filtering returns only reports that have at least one enabled category in them by searching in Onyx storage for the list of ONYXKEYS.COLLECTION.POLICY_CATEGORIES and then each of them for enabled categories.

What changes do you think we should make in order to solve the problem?

We should change the approach to use the areCategoriesEnabled boolean in the policy data.
Lines

const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${reportOption.policyID}`] ?? {};
if (getEnabledCategoriesCount(policyCategories) !== 0) {
recentReportOptions.push(reportOption);
}

Should be replaced with:

      const reportOptionPolicy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportOption.policyID}`] ?? {};
      if (reportOptionPolicy.areCategoriesEnabled) {
          recentReportOptions.push(reportOption);
      }

And after that we need to remove the connection to ONYXKEYS.COLLECTION.POLICY_CATEGORIES that we won't need anymore:
https://github.com/Expensify/App/blob/156f0a2bd0e94558ad621caa701bd749dd124bfe/src/libs/OptionsListUtils.ts#L279-284

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Aug 26, 2024
Copy link

melvin-bot bot commented Aug 27, 2024

@dylanexpensify Eep! 4 days overdue now. Issues have feelings too...

@dylanexpensify dylanexpensify added the External Added to denote the issue can be worked on by a contributor label Aug 28, 2024
@melvin-bot melvin-bot bot changed the title Categorize - Unable to search for workspace chats if the reports are not visited previously [$250] Categorize - Unable to search for workspace chats if the reports are not visited previously Aug 28, 2024
Copy link

melvin-bot bot commented Aug 28, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01570efd314fb561ac

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 28, 2024
Copy link

melvin-bot bot commented Aug 28, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (External)

@melvin-bot melvin-bot bot removed the Overdue label Aug 28, 2024
@dukenv0307
Copy link
Contributor

@dylanexpensify I think it's BE bug, OpenApp API doesn't return the category of other WS if we have many workspaces.

If it's intended behavior, do we have the API to load the category if needed?

Copy link

melvin-bot bot commented Sep 2, 2024

@dylanexpensify, @dukenv0307 Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Sep 2, 2024
Copy link

melvin-bot bot commented Sep 4, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

Copy link

melvin-bot bot commented Sep 4, 2024

@dylanexpensify, @dukenv0307 Still overdue 6 days?! Let's take care of this!

Copy link

melvin-bot bot commented Sep 5, 2024

@dylanexpensify @dukenv0307 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Sep 6, 2024

@dylanexpensify, @dukenv0307 Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

@trjExpensify
Copy link
Contributor

@dylanexpensify I think it's BE bug, OpenApp API doesn't return the category of other WS if we have many workspaces.

If it's intended behavior, do we have the API to load the category if needed?

@dylanexpensify we need to get the answer to this to move it on. @thienlnam would be good to ask here for the Track > categorize it flow.

@trjExpensify trjExpensify changed the title [$250] Categorize - Unable to search for workspace chats if the reports are not visited previously [$250] Track > Categorize it flow - Unable to search for workspace chats if the reports are not visited previously Sep 10, 2024
@dylanexpensify
Copy link
Contributor

Apologies, assigning star to me and getting clarification!

@melvin-bot melvin-bot bot removed the Overdue label Sep 10, 2024
@thienlnam
Copy link
Contributor

This looks like an issue with createWorkspace not sending a pusher update for policy categories. I don't think that we did this on purpose to save onyx storage or anything so yeah this would require a BE fix

@trjExpensify
Copy link
Contributor

Hm, I'm a bit confused. When you choose to Categorize it, shouldn't we check if you are a member of any workspaces and return all the newDot compatible ones in the picker? Otherwise, we proceed to create you one and show a list of categories.

@thienlnam
Copy link
Contributor

Yeah, that should happen - but it sounds like we're not returning the categories of all the workspaces so we don't have those stored to determine which ones are compatible for the Categorize it option.

@thienlnam
Copy link
Contributor

I've been chatting on this and have the context so I can take over the issue

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 19, 2024
Copy link

melvin-bot bot commented Sep 19, 2024

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Sep 19, 2024

📣 @jaydamani 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@thienlnam
Copy link
Contributor

@jaydamani You can test the solution with the OpenPolicyCategoriesPage endpoint for now

Copy link

melvin-bot bot commented Sep 19, 2024

@thienlnam @dylanexpensify @jaydamani @dukenv0307 this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

@jaydamani
Copy link
Contributor

It is working as expected. Should I raise a PR with this API or do you want to use a new one?

New.Expensify.-.Google.Chrome.2024-09-20.01-03-45.mp4

@thienlnam
Copy link
Contributor

I have a PR in review for a new endpoint called 'GetPolicyCategories', it's not live yet but should be early next week

@jaydamani
Copy link
Contributor

I have a PR in review for a new endpoint called 'GetPolicyCategories', it's not live yet but should be early next week

I will create a PR for frontend after new endpoint is deployed

@melvin-bot melvin-bot bot added the Overdue label Sep 23, 2024
@dukenv0307
Copy link
Contributor

@thienlnam any updates?

@thienlnam
Copy link
Contributor

New endpoint is on staging right now, should be on prod later today

Copy link

melvin-bot bot commented Sep 24, 2024

@thienlnam, @dylanexpensify, @jaydamani, @dukenv0307 Eep! 4 days overdue now. Issues have feelings too...

@jaydamani
Copy link
Contributor

@thienlnam please share the details of new end point

@thienlnam
Copy link
Contributor

It's the same as OpenPolicyCategoriesPage, just a different alias GetPolicyCategories. You can use it in the exact same way

@thienlnam
Copy link
Contributor

Should be live now

@melvin-bot melvin-bot bot removed the Overdue label Sep 24, 2024
@dylanexpensify
Copy link
Contributor

NICE!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 25, 2024
@jaydamani
Copy link
Contributor

Created a PR here

@dylanexpensify
Copy link
Contributor

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Status: Polish
Development

No branches or pull requests

8 participants