Skip to content

[HOLD for payment 2024-12-07] [$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page #47975

Closed

Description

@IuliiaHerets

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.0.24-1
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com
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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 24, 2024
  2. melvin-bot commented on Aug 24, 2024

    @melvin-bot

    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.

  3. IuliiaHerets commented on Aug 24, 2024

    @IuliiaHerets
    Author

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

  4. IuliiaHerets commented on Aug 24, 2024

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

  5. Krishna2323 commented on Aug 25, 2024

    @Krishna2323
    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
  6. stephanieelliott commented on Aug 28, 2024

    @stephanieelliott
    Contributor

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

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 28, 2024
  8. 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[/+] on Aug 28, 2024
  9. melvin-bot commented on Aug 28, 2024

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 28, 2024
  11. 76 remaining items

  12. melvin-bot commented on Nov 30, 2024

    @melvin-bot

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

  13. melvin-bot commented on Nov 30, 2024

    @melvin-bot

    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:

  14. melvin-bot commented on Nov 30, 2024

    @melvin-bot

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

  15. moved this from Bugs and Follow Up Issues to Hold for Payment in #expensify-bugson Dec 10, 2024
  16. alitoshmatov commented on Dec 10, 2024

    @alitoshmatov
    Contributor

    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

  17. stephanieelliott commented on Dec 11, 2024

    @stephanieelliott
    Contributor

    Summarizing payment on this issue:

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

  18. moved this from Hold for Payment to Done in #expensify-bugson Dec 11, 2024
  19. JmillsExpensify commented on Dec 11, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @alitoshmatov

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