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

[HOLD for payment 2025-01-13] Expense - Inconsistency in category and tax change system message when editing category #54559

Closed
8 tasks done
IuliiaHerets opened this issue Dec 25, 2024 · 15 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Dec 25, 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.78-2
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Rules and Taxes are enabled.
  • There are two tax rates - A and B.
  • Tax rate A belongs to Workspace and Foreign currency default.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Click Advertising category.
  4. Click Default tax rate.
  5. Select Tax rate B.
  6. Go to workspace chat.
  7. Submit an expense without category.
  8. Go to transaction thread.
  9. Click Category and select Advertising.
  10. Note that the system message starts with tax rate first, then category.
  11. Click Category and select any other category.
  12. Note that the system message starts with category first, then tax rate.
  13. Click Category and click on the same category to unselect it.
  14. Note that the system message starts with tax rate first, then category.

Expected Result:

In Step 10, 12 and 14, when setting, changing and removing category from the expense, the system message should be consistent.

Actual Result:

When setting category (step 10), the system message starts with tax rate first, then category. The messages appear in two lines.

When changing category (step 12), the system message starts with category first, then tax rate. Both messages appear in one line.

When removing category (step 14), the system message starts with tax rate first, then category. The messages appear in two lines.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6701996_1735111142157.20241225_151152.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @bfitzexpensify
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Dec 25, 2024
Copy link

melvin-bot bot commented Dec 25, 2024

Triggered auto assignment to @Beamanator (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Dec 25, 2024

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

@melvin-bot melvin-bot bot added the Daily KSv2 label Dec 25, 2024
Copy link

melvin-bot bot commented Dec 25, 2024

💬 A slack conversation has been started in #expensify-open-source

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Dec 25, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@Beamanator
Copy link
Contributor

commented in the slack thread about the PR i think is responsible - prooobs this doesn't need to be a blocker 🤔

cc @bernhardoj @MonilBhavsar in case y'all can take a look

@allgandalf
Copy link
Contributor

prooobs this doesn't need to be a blocker

Agree, functionality isn't affected by this regression !

Copy link

melvin-bot bot commented Dec 25, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@ijmalik
Copy link
Contributor

ijmalik commented Dec 25, 2024

Proposal

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

Expense - Discrepancy in system messages for category and tax changes during category edits

What is the root cause of that problem?

The inconsistency arises due to the logic implemented in the following section of the code:

const message =
getMessageLine(`\n${Localize.translateLocal('iou.changed')}`, changeFragments) +
getMessageLine(`\n${Localize.translateLocal('iou.set')}`, setFragments) +
getMessageLine(`\n${Localize.translateLocal('iou.removed')}`, removalFragments);

The system categorizes changes into three types:

  1. Set: Items being added for the first time are displayed on the first line.

  2. Change: Items that are modified are displayed on the second line.

  3. Removal: Items that are deleted are displayed on the third line.

This logic results in inconsistencies when displaying messages:

If a category is set for the first time, it appears on the second line.
If a category is modified, it appears on the first line.
If a category is removed, it appears on the third line.

Examples of Current Behavior

changed the tax rate to 5% (previously 0%)
set the category to "Advertising"

changed the category to "Car" (previously "Advertising") and the tax rate to 0% (previously 5%)

changed the tax rate to 0% (previously 5%)
removed the category (previously "Advertising")

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

Replace

const message =
getMessageLine(`\n${Localize.translateLocal('iou.changed')}`, changeFragments) +
getMessageLine(`\n${Localize.translateLocal('iou.set')}`, setFragments) +
getMessageLine(`\n${Localize.translateLocal('iou.removed')}`, removalFragments);
if (message === '') {
return Localize.translateLocal('iou.changedTheExpense');
}
return `${message.substring(1, message.length)}`;
}

With

    const prefixMapping = new Map([
        [setFragments, 'iou.set'],
        [changeFragments, 'iou.changed'],
        [removalFragments, 'iou.removed'],
    ]);
    
    const prefixedFragments = [...setFragments, ...changeFragments, ...removalFragments]
        .sort()
        .map((item) => {
            for (const [fragmentGroup, prefixKey] of prefixMapping) {
                if (fragmentGroup.includes(item)) {
                    return `${Localize.translateLocal(prefixKey as 'iou.set' | 'iou.changed' | 'iou.removed')} ${item}`;
                }
            }
            return '';
        });   
    
    const message = getMessageLine(prefixedFragments)

    if (message === '') {
        return Localize.translateLocal('iou.changedTheExpense');
    }
    return message;

Replace

function getMessageLine(prefix: string, messageFragments: string[]): string {
if (messageFragments.length === 0) {
return '';
}
return messageFragments.reduce((acc, value, index) => {
if (index === messageFragments.length - 1) {
if (messageFragments.length === 1) {
return `${acc} ${value}`;
}
if (messageFragments.length === 2) {
return `${acc} ${Localize.translateLocal('common.and')} ${value}`;
}
return `${acc}, ${Localize.translateLocal('common.and')} ${value}`;
}
if (index === 0) {
return `${acc} ${value}`;
}
return `${acc}, ${value}`;
}, prefix);
}

with

function getMessageLine(messageFragments: string[]): string {
    if (!Array.isArray(messageFragments) || messageFragments.length === 0) {
        return '';
    }
    return messageFragments.reduce((acc, value, index) => {
        if (index === messageFragments.length - 1) {
            if (messageFragments.length === 1) {
                return `${acc} ${value}`;
            }
            if (messageFragments.length === 2) {
                return `${acc} ${Localize.translateLocal('common.and')} ${value}`;
            }
            return `${acc}, ${Localize.translateLocal('common.and')} ${value}`;
        }
        if (index === 0) {
            return `${acc} ${value}`;
        }
        return `${acc}, ${value}`;
    });
}

Note:
The above code can be further optimized for if necessary, but it resolves the inconsistency effectively.

What alternative solutions did you explore? (Optional)

After Code Change:
messages-after

@Beamanator Beamanator added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Dec 26, 2024
@Beamanator
Copy link
Contributor

Downgrading to "not a blocker" due to some convos in slack - in this thread

Still discussing if this is a real issue or not

@ijmalik thanks for your proposal, I am still checking if this is a bug or not, will open it up for reviewing your proposal if we agree this is a bug 🙏

@bernhardoj
Copy link
Contributor

Handling this in #54579

@MonilBhavsar MonilBhavsar self-assigned this Dec 26, 2024
@MonilBhavsar MonilBhavsar added the Reviewing Has a PR in review label Dec 27, 2024
Copy link

melvin-bot bot commented Jan 6, 2025

@Beamanator, @MonilBhavsar, @bfitzexpensify Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jan 6, 2025
@melvin-bot melvin-bot bot added the Awaiting Payment Auto-added when associated PR is deployed to production label Jan 6, 2025
@melvin-bot melvin-bot bot changed the title Expense - Inconsistency in category and tax change system message when editing category [HOLD for payment 2025-01-13] Expense - Inconsistency in category and tax change system message when editing category Jan 6, 2025
Copy link

melvin-bot bot commented Jan 6, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 6, 2025
Copy link

melvin-bot bot commented Jan 6, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.80-6 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-01-13. 🎊

Copy link

melvin-bot bot commented Jan 6, 2025

@Beamanator / @MonilBhavsar @bfitzexpensify @Beamanator / @MonilBhavsar 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]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

Skipping the payment summary for this issue since all the assignees are employees or vendors. If this is incorrect, please manually add the payment summary SO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering
Projects
None yet
Development

No branches or pull requests

7 participants