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 2023-12-20] [$500] Web - Split Scan - Console error shows up when clicking Split on empty split action menu #32809

Closed
1 of 6 tasks
kbecciv opened this issue Dec 11, 2023 · 34 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 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Dec 11, 2023

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: v1.4.11-1
Reproducible in staging?: y
Reproducible in production?: n
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to staging.new.expensify.com.
  2. Go to workspace chat > + > Split bill > Scan.
  3. Create a split scan request.
  4. Click on the spit preview.
  5. Click Split.

Expected Result:

No console error shows up.

Actual Result:

Console error shows up.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

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

Screenshots/Videos

Add any screenshot/video evidence

Bug6308982_1702302781697.bandicam_2023-12-11_20-01-06-062__1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014fa32ba034ba77de
  • Upwork Job ID: 1734211176724713472
  • Last Price Increase: 2023-12-11
  • Automatic offers:
    • shubham1206agra | Reviewer | 28035520
    • bernhardoj | Contributor | 28035524
@kbecciv kbecciv added the DeployBlockerCash This issue or pull request should block deployment label Dec 11, 2023
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.

Copy link

melvin-bot bot commented Dec 11, 2023

Triggered auto assignment to @mountiny (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@mountiny mountiny added the External Added to denote the issue can be worked on by a contributor label Dec 11, 2023
@melvin-bot melvin-bot bot changed the title Web - Split Scan - Console error shows up when clicking Split on empty split action menu [$500] Web - Split Scan - Console error shows up when clicking Split on empty split action menu Dec 11, 2023
Copy link

melvin-bot bot commented Dec 11, 2023

Job added to Upwork: https://www.upwork.com/jobs/~014fa32ba034ba77de

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 11, 2023
Copy link

melvin-bot bot commented Dec 11, 2023

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

@mountiny
Copy link
Contributor

Most likely related to the refactor #28618

@abzokhattab
Copy link
Contributor

abzokhattab commented Dec 11, 2023

Proposal

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

Err occur when clicking on empty split action menu

What is the root cause of that problem?

we are not safely accessing the trasnactionID:

    const {transactionID} = updatedTransaction;

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

use lodash get

lodashGet(updatedTransaction,"transactionID")

@tgolen tgolen assigned tgolen and unassigned mountiny and robertKozik Dec 11, 2023
@tgolen
Copy link
Contributor

tgolen commented Dec 11, 2023

I'll take this and look into it this morning.

@mountiny
Copy link
Contributor

@abzokhattab that solution is not enough as there are other properties required which cause console error

@mountiny
Copy link
Contributor

Thanks Tim, I have to head out earlier tonight

@shubham1206agra
Copy link
Contributor

Maybe this will help

const onConfirm = useCallback(
        () => 
        {
            if (!props.draftTransaction) {
                Navigation.dismissModal(reportID);
                return;
            }
            IOU.completeSplitBill(reportID, reportAction, props.draftTransaction, props.session.accountID, props.session.email)
        },
        [reportID, reportAction, props.draftTransaction, props.session.accountID, props.session.email],
    );

@shubham1206agra
Copy link
Contributor

@mountiny Please remove Help wanted label here

@tgolen tgolen removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 11, 2023
@mountiny
Copy link
Contributor

We should show error on the form if the Amount and merchant have not been updated

@shubham1206agra
Copy link
Contributor

I think disabling the button will be more correct

@mountiny
Copy link
Contributor

ah yeah, whatever our Forms.md dictate

@shubham1206agra
Copy link
Contributor

Sorry, we should show error according to Forms.md

@tgolen tgolen removed the External Added to denote the issue can be worked on by a contributor label Dec 11, 2023
@bernhardoj
Copy link
Contributor

Sure, writing it now

@bernhardoj
Copy link
Contributor

Proposal

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

A console error is shown when pressing the Split button on a split bill details page with a receipt and empty required fields.

What is the root cause of that problem?

When we press the split button, we call confirm and have several checks before calling the onConfirm props.

} else {
// validate the amount for distance requests
const decimals = CurrencyUtils.getCurrencyDecimals(props.iouCurrencyCode);
if (props.isDistanceRequest && !isDistanceRequestWithoutRoute && !MoneyRequestUtils.validateAmount(String(props.iouAmount), decimals)) {
setFormError('common.error.invalidAmount');
return;
}
if (props.isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction)) {
setDidConfirmSplit(true);
setFormError('iou.error.genericSmartscanFailureMessage');
return;
}
setDidConfirm(true);
onConfirm(selectedParticipants);
}

If the split transaction data is empty, it should show a required fields error (iou.error.genericSmartscanFailureMessage), but TransactionUtils.areRequiredFieldsEmpty always returns false, thus the onConfirm is called and then completeSplitBill is called with an undefined draftTransaction.

const onConfirm = useCallback(
() => IOU.completeSplitBill(reportID, reportAction, props.draftTransaction, props.session.accountID, props.session.email),
[reportID, reportAction, props.draftTransaction, props.session.accountID, props.session.email],
);

In completeSplitBill, we try to get the transactionID from the undefined transaction, so an error is thrown.

const {transactionID} = updatedTransaction;

TransactionUtils.areRequiredFieldsEmpty is always false because we pass an empty transaction object to it, but it expects the object to have a property like amount.

function areRequiredFieldsEmpty(transaction: Transaction): boolean {
return isMerchantMissing(transaction) || isAmountMissing(transaction) || isCreatedMissing(transaction);
}

function isAmountMissing(transaction: Transaction) {
return transaction.amount === 0 && (!transaction.modifiedAmount || transaction.modifiedAmount === 0);
}

The transaction object comes from SplitBillDetailsPage where we pass a draftTransaction to it.

transaction={isEditingSplitBill ? props.draftTransaction : props.transaction}

But draftTransaction is undefined if we never edit the transaction and transaction props in SplitBillDetailPage have a default props of an empty object ({}).

Before, we fall back to transaction.
image

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

Fall back to transaction if draftTransaction doesn't exist.

In SplitBillDetailsPage

transaction={isEditingSplitBill ? props.draftTransaction : props.transaction}

transaction={isEditingSplitBill ? props.draftTransaction || props.transaction : props.transaction}

@tgolen
Copy link
Contributor

tgolen commented Dec 11, 2023

Thanks, that looks great. Assigning to you now.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 11, 2023
Copy link

melvin-bot bot commented Dec 11, 2023

📣 @shubham1206agra 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Dec 11, 2023

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

@bernhardoj
Copy link
Contributor

PR is ready

@luacmartins luacmartins removed the DeployBlockerCash This issue or pull request should block deployment label Dec 12, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 13, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - Split Scan - Console error shows up when clicking Split on empty split action menu [HOLD for payment 2023-12-20] [$500] Web - Split Scan - Console error shows up when clicking Split on empty split action menu Dec 13, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 13, 2023
Copy link

melvin-bot bot commented Dec 13, 2023

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

Copy link

melvin-bot bot commented Dec 13, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.11-25 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 2023-12-20. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

Copy link

melvin-bot bot commented Dec 13, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@shubham1206agra] The PR that introduced the bug has been identified. Link to the PR:
  • [@shubham1206agra] 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:
  • [@shubham1206agra] A discussion in #expensify-bugs 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:
  • [@shubham1206agra] Determine if we should create a regression test for this bug.
  • [@shubham1206agra] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@puneetlath
Copy link
Contributor

@shubham1206agra friendly reminder on the checklist so that we can pay this out tomorrow.

@shubham1206agra
Copy link
Contributor

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

@puneetlath
Copy link
Contributor

Great. @shubham1206agra can you also accept the upwork offer linked above?

@shubham1206agra
Copy link
Contributor

Done

@puneetlath
Copy link
Contributor

All paid. Thanks everyone!

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

No branches or pull requests

9 participants