Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.57k stars 2.91k forks source link

Track expense- Category list loads infinitely when categorizing expense from invited workspace #52834

Open IuliiaHerets opened 1 day ago

IuliiaHerets commented 1 day ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.64-4 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y Email or phone of affected tester (no customers): applausetester+kh0711008@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. [User A] Invite User B to workspace.
  3. [User B] Do not open workspace chat invited by User A.
  4. [User B] Go to self DM.
  5. [User B] Track a manual expense.
  6. [User B] Select Categorize it from the actionable whisper.
  7. [User B] Click on the invited workspace.

Expected Result:

Category list will load without issue.

Actual Result:

Category list loads infinitely when categorizing expense from invited workspace and the invited workspace chat has not been opened yet.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/18eb49b0-fe39-4192-8bad-259b8e0fabe4

View all open jobs on GitHub

melvin-bot[bot] commented 1 day ago

Triggered auto assignment to @johncschuster (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.

huult commented 1 day ago

Edited by proposal-police: This proposal was edited at 2024-11-21 13:54:21 UTC.

Proposal

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

Category list loads infinitely when categorizing expense from invited workspace

What is the root cause of that problem?

This is a backend issue. We are unable to get policy categories.

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

To resolve this issue, we must update the backend or if we don't want to update it, we can use 'openReport' instead of fetching policy categories because categories are included in the response of openReport, and we can use them directly. Something like this:

https://github.com/Expensify/App/blob/4a7f23f1d84568464228392f737317b58a10dde4/src/pages/iou/request/step/IOURequestStepCategory.tsx#L87-L93

// src/pages/iou/request/step/IOURequestStepCategory.tsx#L87

    const fetchData = () => {
        if (policy && policyCategories) {
            return;
        }
+        if (report?.reportID) {
+            Report.openReport(report?.reportID, report?.reportActionID);
+        }
        Category.getPolicyCategories(report?.policyID ?? '-1');
    };
POC https://github.com/user-attachments/assets/e4457f1b-8c78-474a-9f50-e82fa196f17e

What alternative solutions did you explore? (Optional)

we can create a new useEffect to watch for when we call Category.getPolicyCategories(report?.policyID ?? '-1'). If policyCategories returns undefined, we must call Report.openReport(report?.reportID, report?.reportActionID);.

// src/pages/iou/request/step/IOURequestStepCategory.tsx#L86
    useEffect(() => {
        if (isLoadingOnyxValue(policyCategoriesRealResult) || isLoadingOnyxValue(policyCategoriesDraftResult)) {
            return;
        }

        if (!policyCategories && report?.reportID) {
            Report.openReport(report?.reportID, report?.reportActionID);
        }
    }, [policyCategories, policyCategoriesDraftResult, policyCategoriesRealResult, report?.reportActionID, report?.reportID]);