Skip to content

[Due for payment 2025-06-27] [$250] Workspace - In offline, in preview red dot not displayed and category no longer valid not shown #61306

Closed

Description

@jponikarchuk

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: V9.1.39-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
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): Slottwo1 sivappa3@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote note 10s android 13
App Component: Money Requests

Action Performed:

  1. Launch app
  2. Open a workspace chat
  3. Create a manual expense with advertisement category
  4. Go to category page
  5. Turn off internet
  6. Tap advertisement and delete the category
  7. Go back to workspace chat
  8. Turn on internet

Expected Result:

In offline, in preview red dot must be displayed and category no longer valid message must be shown.

Actual Result:

In offline, in preview red dot not displayed and category no longer valid not shown.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021920547540652397343
  • Upwork Job ID: 1920547540652397343
  • Last Price Increase: 2025-05-08
  • Automatic offers:
    • Tony-MK | Contributor | 107310090
Issue OwnerCurrent Issue Owner: @strepanier03

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 2, 2025
  2. melvin-bot commented on May 2, 2025

    @melvin-bot

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

  3. Tony-MK commented on May 4, 2025

    @Tony-MK
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-05-14 15:21:30 UTC.

    Proposal

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

    Workspace - In offline, in preview red dot is not displayed, andthe category is no longer valid not shown

    What is the root cause of that problem?

    The deleteWorkspaceCategories function does not optimistically push the new categoryOutOfPolicy transaction violation to optimisticData.

    function deleteWorkspaceCategories(policyID: string, categoryNamesToDelete: string[]) {
    const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
    const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`] ?? {};
    const optimisticPolicyCategoriesData = categoryNamesToDelete.reduce<Record<string, Partial<PolicyCategory>>>((acc, categoryName) => {
    acc[categoryName] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, enabled: false};
    return acc;
    }, {});
    const shouldDisableRequiresCategory = !hasEnabledOptions(
    Object.values(policyCategories).filter((category) => !categoryNamesToDelete.includes(category.name) && category.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE),
    );
    const onyxData: OnyxData = {
    optimisticData: [

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

    Let's create a function, eg, getTransactionsViolationsOnyxData, that can use ViolationsUtils.getViolationsOnyxData to get the OnyxData of each transaction, if the policy or its categories or tag lists are updated or optimistic.

    function getTransactionsViolationsOnyxData(
        policyID: string,
        optimisticPolicy: OnyxEntry<Policy> | undefined, 
        optimisticPolicyTagLists: OnyxEntry<PolicyTagLists> | undefined,
        optimisticPolicyCategories:  OnyxEntry<PolicyCategories> | undefined, 
    ): OnyxData {
        const onyxData: { optimisticData: OnyxUpdate[]; failureData: OnyxUpdate[] } = {optimisticData: [], failureData: []};
        const policy = optimisticPolicy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
       
        if (
            isEmptyObject(policy) ||
            (isEmptyObject(optimisticPolicy) && isEmptyObject(optimisticPolicyTagLists) && isEmptyObject(optimisticPolicyCategories))
         ) {
             return onyxData;
         }
    
        const policyTagLists =  optimisticPolicyTagLists ?? allPolicyTagLists?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {};
        const policyCategories = optimisticPolicyCategories ?? allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`] ?? {};
        const hasDependentTags = hasDependentTagsUtils(policy, policyTagLists);
    
       getAllPolicyReports(policyID).forEach((report) => {
            if (!report?.reportID){
                return;
            }
    
            const isInvoiceReport = isInvoiceReportUtils(report)
    
            getReportTransactions(report.reportID).forEach((transaction: Transaction) => {
                const transactionViolations = allTransactionViolations?.[transaction.transactionID] ?? [];
                const transactionViolationsOnyxData = ViolationsUtils.getViolationsOnyxData(
                    transaction,
                    transactionViolations, 
                    policy,
                    policyTagLists, 
                    policyCategories, 
                    hasDependentTags, 
                    isInvoiceReport,
                );
            
                if (transactionViolationsOnyxData){
                    onyxData.optimisticData.push(transactionViolationsOnyxData);
                    onyxData.failureData.push({
                        onyxMethod: Onyx.METHOD.MERGE,
                        key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
                        value: transactionViolations,
                    });
                }
            });
        });
        return onyxData;
    }

    Use getTransactionsViolationsOnyxData in the functions that need the policy's updated transaction violations, such as deleteWorkspaceCategories.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Create tests for deleteWorkspaceCategories to check whether the categoryOutOfPolicy violation is in optimisticData and other functions that require updating the policy's transaction violation onyx.

    What alternative solutions did you explore? (Optional)

    N/A

  4. melvin-bot commented on May 5, 2025

    @melvin-bot

    @strepanier03 Whoops! This issue is 2 days overdue. Let's get this updated quick!

  5. melvin-bot commented on May 7, 2025

    @melvin-bot

    @strepanier03 Huh... This is 4 days overdue. Who can take care of this?

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 8, 2025
  7. changed the title [-]Workspace - In offline, in preview red dot not displayed and category no longer valid not shown[/-] [+][$250] Workspace - In offline, in preview red dot not displayed and category no longer valid not shown[/+] on May 8, 2025
  8. melvin-bot commented on May 8, 2025

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 8, 2025
  10. melvin-bot commented on May 8, 2025

    @melvin-bot

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

  11. 32 remaining items

  12. melvin-bot commented on Jun 20, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.69-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-06-27. 🎊

    For reference, here are some details about the assignees on this issue:

  13. melvin-bot commented on Jun 20, 2025

    @melvin-bot

    @mananjadhav @strepanier03 @mananjadhav The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. strepanier03 commented on Jun 27, 2025

    @strepanier03
    Contributor

    Payment Summary

  15. mananjadhav commented on Jun 27, 2025

    @mananjadhav
    Collaborator

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: I would treat this as a feature request and a case we didn't consider earlier.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    I think this needs to be covered with a regression test.

    Regression Test Proposal

    Test Case 1:

    1. Create a new workspace.
    2. Create a manual expense with a category.
    3. Open the expense report by clicking the report preview.
    4. Confirm the expense as no violations.
    5. Go to the category page.
    6. Go offline.
    7. Delete the category used in step 2.
    8. Go back to the expense report.
    9. Confirm the category field displays a violation that reads "Category no longer valid".
    10. Go online.
    11. Confirm the violation persists.

    Test Case 2:

    1. Go Offline
    2. Update the category of an expense that has no violations.
    3. Delete a category used in step 2.
    4. Go back to the expense report.
    5. Confirm the category field displays a violation that reads "Category no longer valid".
    6. Update the category of an expense.
    7. Confirm the violation is cleared.
    8. Go online.
    9. Confirm the violation is still cleared.

    Test Case 3:

    1. Delete an expense.
    2. In the same workspace, create a manual expense with a category.
    3. Go Offline.
    4. Delete a category used in step 2.
    5. Go back to the expense report.
    6. Confirm the category field displays a violation that reads "Category no longer valid".
    7. Go online.
    8. Confirm the violation persists.

    Do we agree 👍 or 👎

    @strepanier03 ^

  16. mananjadhav commented on Jun 30, 2025

    @mananjadhav
    Collaborator

    @strepanier03 This is all set to be closed.

  17. strepanier03 commented on Jun 30, 2025

    @strepanier03
    Contributor

    @mananjadhav - I removed the hold from the payment summary.

    Closing out.

  18. garrettmknight commented on Jul 3, 2025

    @garrettmknight
    Contributor

    $250 approved for @mananjadhav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions