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

[$250] [Dupe detection] Tax field does not show the "Default" label on the confirmation page #47975

Open
6 tasks done
IuliiaHerets opened this issue Aug 24, 2024 · 27 comments
Open
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

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-08-28
@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.

@pecanoro
Copy link
Contributor

I still think we should wait since the proposals are really similar, and they will need to be updated accordingly.

@melvin-bot melvin-bot bot added the Overdue label Aug 30, 2024
Copy link

melvin-bot bot commented Sep 2, 2024

@pecanoro, @stephanieelliott, @alitoshmatov Huh... This is 4 days overdue. Who can take care of this?

@pecanoro pecanoro added the Weekly KSv2 label Sep 3, 2024
@pecanoro pecanoro removed the Daily KSv2 label Sep 3, 2024
@melvin-bot melvin-bot bot removed the Overdue label Sep 3, 2024
@stephanieelliott
Copy link
Contributor

Still holding on #47974

1 similar comment
@stephanieelliott
Copy link
Contributor

Still holding on #47974

@melvin-bot melvin-bot bot added the Overdue label Sep 17, 2024
@pecanoro
Copy link
Contributor

Still holding

@melvin-bot melvin-bot bot removed the Overdue label Sep 17, 2024
@melvin-bot melvin-bot bot added the Overdue label Sep 25, 2024
@stephanieelliott
Copy link
Contributor

Still holding on #47974

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2024
@stephanieelliott
Copy link
Contributor

Im not able to reproduce this anymore -- can anyone else repro?

@Krishna2323
Copy link
Contributor

@stephanieelliott, issue is still reproducible.

Monosnap.screencast.2024-10-04.08-32-51.mp4

@stephanieelliott
Copy link
Contributor

Ok @Krishna2323 can you make any necessary updates to your proposal, then let us know when it's ready so @alitoshmatov can review?

@stephanieelliott
Copy link
Contributor

Bump on the above @Krishna2323, did still want to work on this?

@Krishna2323
Copy link
Contributor

@stephanieelliott, I will update my proposal/test branch today.

@stephanieelliott
Copy link
Contributor

Hey @Krishna2323 have you had a chance to update the proposal?

@Krishna2323
Copy link
Contributor

Krishna2323 commented Oct 17, 2024

@stephanieelliott sorry for the delay, I have updated the main solution's test branch. @alitoshmatov can start reviewing.

@alitoshmatov Let me know if you need a test branch for alternative solution too.

@stephanieelliott
Copy link
Contributor

Hey @alitoshmatov can you review the updated proposal? #47975 (comment)

@stephanieelliott stephanieelliott changed the title [HOLD 47974] [$250] [Dupe detection] 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 Oct 26, 2024
@stephanieelliott stephanieelliott added Daily KSv2 and removed Weekly KSv2 labels Oct 26, 2024
@melvin-bot melvin-bot bot added the Overdue label Oct 26, 2024
@stephanieelliott
Copy link
Contributor

Hey @alitoshmatov can you review the updated proposal? #47975 (comment)

Bump @alitoshmatov

@melvin-bot melvin-bot bot removed the Overdue label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: Polish
Development

No branches or pull requests

7 participants