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 2024-12-07] [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page #47975

Closed
6 tasks done
IuliiaHerets opened this issue Aug 24, 2024 · 46 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 External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 24, 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: v9.0.24-1
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • Track tax is enabled in Workspace settings > Distance rates > Settings.
  • Distance rate has Tax rate and Tax reclaimable fields populated.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit two same distance expenses with the same distance rate that has tax rate and tax reclaimable on.
  4. Go to transaction thread of any submitted expense.
  5. Note that Tax field has the "Default" label.
  6. Click Review duplicates.
  7. Click Keep this on (any).
  8. Proceed to confirmation page.

Expected Result:

Tax field will show the "Default" label on the confirmation page.

Actual Result:

Tax field does not show the "Default" label on the confirmation page and instead shows "None"

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6581494_1724513644363.20240824_232902.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017284a9effe70faa8
  • Upwork Job ID: 1828590697351581643
  • Last Price Increase: 2024-11-13
  • Automatic offers:
    • Krishna2323 | Contributor | 104974640
Issue OwnerCurrent Issue Owner: @stephanieelliott
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 24, 2024
Copy link

melvin-bot bot commented Aug 24, 2024

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

@IuliiaHerets
Copy link
Author

We think that this bug might be related to #wave-control

@IuliiaHerets
Copy link
Author

@stephanieelliott 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

@Krishna2323
Copy link
Contributor

Proposal

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

Dupe detect - Tax field does not show the "Default" label on the confirmation page

What is the root cause of that problem?

  • To get the default tax rate we need comment?.customUnit?.customUnitRateID?.toString(); in the transactionID.

    /**
    * Get rate ID from the transaction object
    */
    function getRateID(transaction: OnyxInputOrEntry<Transaction>): string | undefined {
    return transaction?.comment?.customUnit?.customUnitRateID?.toString();
    }
    /**
    * Gets the tax code based on the type of transaction and selected currency.
    * If it is distance request, then returns the tax code corresponding to the custom unit rate
    * Else returns policy default tax rate if transaction is in policy default currency, otherwise foreign default tax rate
    */
    function getDefaultTaxCode(policy: OnyxEntry<Policy>, transaction: OnyxEntry<Transaction>, currency?: string | undefined): string | undefined {
    if (isDistanceRequest(transaction)) {
    const customUnitRateID = getRateID(transaction) ?? '';
    const customUnitRate = getCustomUnitRate(policy, customUnitRateID);
    return customUnitRate?.attributes?.taxRateExternalID ?? '';
    }
    const defaultExternalID = policy?.taxRates?.defaultExternalID;
    const foreignTaxDefault = policy?.taxRates?.foreignTaxDefault;
    return policy?.outputCurrency === (currency ?? getCurrency(transaction)) ? defaultExternalID : foreignTaxDefault;
    }

  • But when we call buildNewTransactionAfterReviewingDuplicates on confirmation page the comment object is only left with a comment property, all other properties are removed.

    function buildNewTransactionAfterReviewingDuplicates(reviewDuplicateTransaction: OnyxEntry<ReviewDuplicates>): Partial<Transaction> {
    const originalTransaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${reviewDuplicateTransaction?.transactionID}`] ?? undefined;
    const {duplicates, ...restReviewDuplicateTransaction} = reviewDuplicateTransaction ?? {};
    return {
    ...originalTransaction,
    ...restReviewDuplicateTransaction,
    modifiedMerchant: reviewDuplicateTransaction?.merchant,
    merchant: reviewDuplicateTransaction?.merchant,
    comment: {comment: reviewDuplicateTransaction?.description},
    };
    }

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

When we modify the transaction, we need to store the remaining properties of the comment object. To do this we need to make few changes.

  • We first need to store the comment object in keep object.
    if (allCommentsAreEqual || allCommentsAreEmpty) {
    keep[fieldName] = firstTransaction?.comment?.comment ?? firstTransaction?.comment;
    } else {
                if (allCommentsAreEqual || allCommentsAreEmpty) {
                    keep[fieldName] = firstTransaction?.comment?.comment ?? firstTransaction?.comment;
                    keep.comment = firstTransaction?.comment;
  • In buildNewTransactionAfterReviewingDuplicates, we need to merge the remaining properties of the comment object.
    comment: {comment: reviewDuplicateTransaction?.description},
comment: {...reviewDuplicateTransaction?.comment, comment: reviewDuplicateTransaction?.description},
  • When updating the description in ReviewDescription, we need to find the correct comment object and update it in the REVIEW_DUPLICATES ONYX object.
    const setDescription = (data: FieldItemType<'description'>) => {
    if (data.value !== undefined) {
    setReviewDuplicatesKey({description: data.value});
    }
    navigateToNextScreen();
    };
            const comment = compareResult.change.description?.find((d) => d?.comment === data.value);
            setReviewDuplicatesKey({description: data.value, comment});

Test Branch

What alternative solutions did you explore? (Optional)


Alternatively we can store the comment object with updated comment instead of description text:

if (fieldName === 'description') {
const allCommentsAreEqual = areAllCommentsEqual(transactions, firstTransaction);
const allCommentsAreEmpty = isFirstTransactionCommentEmptyObject && transactions.every((item) => item?.comment === undefined);
if (allCommentsAreEqual || allCommentsAreEmpty) {
keep[fieldName] = firstTransaction?.comment?.comment ?? firstTransaction?.comment;

NOTE: We also need to make changes in few other files. The changes are bit similar to solution above. Please checkout the text branch below for a better understanding.

Test Branch - Alternative Solution

Result

Monosnap.screencast.2024-08-25.06-52-08.mp4

@melvin-bot melvin-bot bot added the Overdue label Aug 27, 2024
@stephanieelliott
Copy link
Contributor

updated the repro steps slightly -- actual result shows None instead of the expected default rate.

@melvin-bot melvin-bot bot removed the Overdue label Aug 28, 2024
@stephanieelliott stephanieelliott 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 Dupe detect - Tax field does not show the "Default" label on the confirmation page [$250] Dupe detect - Tax field does not show the "Default" label on the confirmation page Aug 28, 2024
Copy link

melvin-bot bot commented Aug 28, 2024

Job added to Upwork: https://www.upwork.com/jobs/~017284a9effe70faa8

@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 - @alitoshmatov (External)

@trjExpensify trjExpensify changed the title [$250] Dupe detect - Tax field does not show the "Default" label on the confirmation page [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page Aug 28, 2024
@trjExpensify
Copy link
Contributor

and another one! CC: @dylanexpensify @pecanoro @parasharrajat @kubabutkiewicz

@pecanoro
Copy link
Contributor

@alitoshmatov Could you review the proposals when you have some time?

@parasharrajat
Copy link
Member

I can do that @pecanoro if needed.

@pecanoro pecanoro changed the title [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page [HOLD 47974] [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page Aug 29, 2024
@pecanoro
Copy link
Contributor

Putting a HOLD here for now since it seems to be the same as #47974

@Krishna2323
Copy link
Contributor

@pecanoro, I have proposals for both issues, and I can assure you that they are different. In this issue, we aren't persisting all the properties of the comment object, whereas in issue #47974, the comparison of the comment.comment string is incorrect.

I think we can remove the hold.

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

melvin-bot bot commented Nov 19, 2024

📣 @Krishna2323 🎉 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 📖

@Krishna2323
Copy link
Contributor

Will raise PR tomorrow. Thanks for waiting🙇🏻

@Krishna2323
Copy link
Contributor

@alitoshmatov PR ready for review ^

@stephanieelliott
Copy link
Contributor

Hey @alitoshmatov the PR is blocked on your review, can you take a look? #52928

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 30, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page [HOLD for payment 2024-12-07] [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page Nov 30, 2024
Copy link

melvin-bot bot commented Nov 30, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 30, 2024
Copy link

melvin-bot bot commented Nov 30, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.68-7 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 2024-12-07. 🎊

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

Copy link

melvin-bot bot commented Nov 30, 2024

@alitoshmatov @stephanieelliott @alitoshmatov 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 Overdue and removed Weekly KSv2 labels Dec 7, 2024
@garrettmknight garrettmknight moved this from Bugs and Follow Up Issues to Hold for Payment in [#whatsnext] #expense Dec 10, 2024
@alitoshmatov
Copy link
Contributor

alitoshmatov commented Dec 10, 2024

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: https://github.com/Expensify/App/pull/42571/files#r1878801476

  • [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: No discussion started

  • [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.

    I don't think regression test is needed

@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

Upwork job is here: https://www.upwork.com/jobs/~017284a9effe70faa8

@melvin-bot melvin-bot bot removed Overdue labels Dec 11, 2024
@github-project-automation github-project-automation bot moved this from Hold for Payment to Done in [#whatsnext] #expense Dec 11, 2024
@JmillsExpensify
Copy link

$250 approved for @alitoshmatov

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 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests

8 participants