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] Expense - Payment sound triggered prematurely when submitting a held expense. #50572

Open
2 of 6 tasks
lanitochka17 opened this issue Oct 10, 2024 · 24 comments
Open
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 10, 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.46-5
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Create a workspace
  3. Navigate to the workspace chat
  4. Submit an expense
  5. Right-click on the submitted expense and select hold
  6. Click the green "Pay" button
  7. Observe that the payment sound is triggered and an additional "Confirm payment amount" modal appears

Expected Result:

For this case the sound indicating a payment should be triggered after the payment is successfully completed. If the expense is on hold, the sound should be delayed until the confirmation is made and finalized

Actual Result:

The payment sound is triggered when the green pay button is clicked, even though the payment is not yet finalized

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
Bug6630541_1728553595243.soundd.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021846013804908725875
  • Upwork Job ID: 1846013804908725875
  • Last Price Increase: 2024-10-22
  • Automatic offers:
    • mkzie2 | Contributor | 104560763
Issue OwnerCurrent Issue Owner: @abdulrahuman5196
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 10, 2024
Copy link

melvin-bot bot commented Oct 10, 2024

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

@mkzie2
Copy link
Contributor

mkzie2 commented Oct 10, 2024

Edited by proposal-police: This proposal was edited at 2023-10-10T10:00:00.

Proposal

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

The payment sound is triggered when the green pay button is clicked, even though the payment is not yet finalized

What is the root cause of that problem?

We're play sound when after selecting payment type in SettlementButton regardless of the issue is on hold or not:

playSound(SOUNDS.SUCCESS);

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

We should not play sound in SettlementButton when the expense is on hold but play it after confirming in the hold modal instead.

  1. Introduce shouldPlaySound in SettlementButton to determine whether to play sound or not
  2. In ReportPreview and MoneyReportHeader, pass shouldPlaySound={isAnyTransactionOnHold}, or hasHeldExpenses:

const isAnyTransactionOnHold = ReportUtils.hasHeldExpenses(moneyRequestReport?.reportID);

} else if (ReportUtils.hasHeldExpenses(iouReport?.reportID)) {
setIsHoldMenuVisible(true);

  1. Play the sound when confirming the hold modal if we PAY the expense:

IOU.payMoneyRequest(paymentType, chatReport, moneyRequestReport, full);

@etCoderDysto
Copy link
Contributor

Proposal

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

Payment sound triggered prematurely when submitting a held expense.

What is the root cause of that problem?

When user clicks pay button while request is on hold we call playSound(SOUNDS.SUCCESS); before calling confirmPayment (onPress(iouPaymentType);)

playSound(SOUNDS.SUCCESS);
onPress(iouPaymentType);

Here since request is onhold, instead of calling IOU.payMoneyRequest, hold modal will be opened here

const confirmPayment = useCallback(
(type: PaymentMethodType | undefined, payAsBusiness?: boolean) => {
if (!type) {
return;
}
setPaymentType(type);
setRequestType(CONST.IOU.REPORT_ACTION_TYPE.PAY);
if (isDelegateAccessRestricted) {
setIsNoDelegateAccessMenuVisible(true);
} else if (ReportUtils.hasHeldExpenses(iouReport?.reportID)) {
setIsHoldMenuVisible(true);
} else if (chatReport && iouReport) {
setIsPaidAnimationRunning(true);
HapticFeedback.longPress();
if (ReportUtils.isInvoiceReport(iouReport)) {
IOU.payInvoice(type, chatReport, iouReport, payAsBusiness);
} else {
IOU.payMoneyRequest(type, chatReport, iouReport);
}

Hence the sound is played but not followed by settling the request

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

  1. Here we should check if the request is held before playing the sound
if (!ReportUtils.hasHeldExpenses(iouReport?.reportID)) {
            playSound(SOUNDS.SUCCESS);
        }

playSound(SOUNDS.SUCCESS);
onPress(iouPaymentType);

2. Play the sound in HoldMenu when user clicks pay button

playSound(SOUNDS.SUCCESS);
IOU.payMoneyRequest(paymentType, chatReport, moneyRequestReport, full);

IOU.payMoneyRequest(paymentType, chatReport, moneyRequestReport, full);

What alternative solutions did you explore? (Optional)

@bernhardoj
Copy link
Contributor

bernhardoj commented Oct 10, 2024

Edited by proposal-police: This proposal was edited at 2024-10-10 14:11:07 UTC.

Proposal

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

Pressing the pay button plays the sound even though a confirm modal shows.

What is the root cause of that problem?

We always play the sound without checking whether there is a held expenses or not.

playSound(SOUNDS.SUCCESS);
onPress(iouPaymentType);

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

Instead of playing the sound when pressing the SettlementButton, we can play it inside the pay function, such as payMoneyRequest, payInvoice, sendMoneyElsewhere, and sendMoneyWithWallet. We will follow the same pattern as completing a task.

playSound(SOUNDS.SUCCESS);
API.write(WRITE_COMMANDS.COMPLETE_TASK, parameters, {optimisticData, successData, failureData});

@melvin-bot melvin-bot bot added the Overdue label Oct 14, 2024
@RachCHopkins
Copy link
Contributor

Easy to repro. It sounds when you hit the green button, not when you confirm.

@melvin-bot melvin-bot bot removed the Overdue label Oct 15, 2024
@RachCHopkins RachCHopkins added the External Added to denote the issue can be worked on by a contributor label Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

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

@melvin-bot melvin-bot bot changed the title Expense - Payment sound triggered prematurely when submitting a held expense. [$250] Expense - Payment sound triggered prematurely when submitting a held expense. Oct 15, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

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

Copy link

melvin-bot bot commented Oct 18, 2024

@RachCHopkins, @abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Oct 18, 2024
@RachCHopkins
Copy link
Contributor

@abdulrahuman5196 we have a number of early proposals here - do any look good to you?

Copy link

melvin-bot bot commented Oct 22, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

Copy link

melvin-bot bot commented Oct 22, 2024

@RachCHopkins, @abdulrahuman5196 Still overdue 6 days?! Let's take care of this!

@abdulrahuman5196
Copy link
Contributor

checking now

@melvin-bot melvin-bot bot removed the Overdue label Oct 23, 2024
@abdulrahuman5196
Copy link
Contributor

Checking again

@abdulrahuman5196
Copy link
Contributor

@mkzie2 's proposal here #50572 (comment) looks good and works well. One suggestion for the PR would be to try and see if we can avoid introducing a new param in the settlement button which is already bloated, instead we can check if the expense is on hold inside the settlement button itself. I can see we already have chatReport there which we can re-use.
All proposals here are almost the same, so going with the first proposal.

🎀 👀 🎀
C+ Reviewed

Copy link

melvin-bot bot commented Oct 23, 2024

Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

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

melvin-bot bot commented Oct 23, 2024

📣 @mkzie2 🎉 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

bernhardoj commented Oct 24, 2024

All proposals here are almost the same, so going with the first proposal.

@abdulrahuman5196 I don't think my proposal is almost the same as the others. My proposal suggesting to follow the same pattern as creating task, which doesn't require any conditional logic.

cc: @carlosmiceli

@carlosmiceli
Copy link
Contributor

@abdulrahuman5196 After looking at @bernhardoj's proposal, I agree that it's not the same. What's the case for the one you selected?

@mkzie2 please let's hold a bit on the PR 🙏

@abdulrahuman5196
Copy link
Contributor

I don't think my proposal is almost the same as the others. My proposal suggesting to follow the same pattern as creating task, which doesn't require any conditional logic.

@bernhardoj Could you kindly elaborate more on your expected changes? Still not sure if different, Maybe I could have misunderstood the proposal.

Copy link

melvin-bot bot commented Oct 24, 2024

@carlosmiceli @RachCHopkins @abdulrahuman5196 @mkzie2 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@bernhardoj
Copy link
Contributor

bernhardoj commented Oct 25, 2024

With my solution, first we will remove the playSound from SettlementButton.

playSound(SOUNDS.SUCCESS);
onPress(iouPaymentType);

Then, play the sound inside IOU.payMoneyRequest (or payInvoice, sendMoneyElsewhere, and sendMoneyWithWallet).

App/src/libs/actions/IOU.ts

Lines 7658 to 7675 in 66112d1

function payMoneyRequest(paymentType: PaymentMethodType, chatReport: OnyxTypes.Report, iouReport: OnyxEntry<OnyxTypes.Report>, full = true) {
if (chatReport.policyID && SubscriptionUtils.shouldRestrictUserBillableActions(chatReport.policyID)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(chatReport.policyID));
return;
}
const paymentSelected = paymentType === CONST.IOU.PAYMENT_TYPE.VBBA ? CONST.IOU.PAYMENT_SELECTED.BBA : CONST.IOU.PAYMENT_SELECTED.PBA;
completePaymentOnboarding(paymentSelected);
const recipient = {accountID: iouReport?.ownerAccountID ?? -1};
const {params, optimisticData, successData, failureData} = getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentType, full);
// For now, we need to call the PayMoneyRequestWithWallet API since PayMoneyRequest was not updated to work with
// Expensify Wallets.
const apiCommand = paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY ? WRITE_COMMANDS.PAY_MONEY_REQUEST_WITH_WALLET : WRITE_COMMANDS.PAY_MONEY_REQUEST;
API.write(apiCommand, params, {optimisticData, successData, failureData});
}

So, we don't play the sound when the button is pressed, but when the pay request is made.

@abdulrahuman5196
Copy link
Contributor

I agree its not the same as the accepted proposal. I think I had initially misunderstood the proposal.
Anyways I will give a check on this again and update with the final result today.

@abdulrahuman5196
Copy link
Contributor

I have checked @bernhardoj proposal. And IMO, the concern I have is, removing playSound(SOUNDS.SUCCESS); from SettlementButton and adding it to places where we would make the API call would cause us to add the playSound in multiple places in IOU functions which would be a duplicate code. And I am not a fan of having UX interaction like playSound to happen from API calling place which would break the UX and network separation.

So I still think the accepted proposal is better. @carlosmiceli. But anyways do let us know your thoughts as well.

@carlosmiceli
Copy link
Contributor

Understood, @abdulrahuman5196, I like your logic here, I just wanted to confirm that proposals were distinct and a clear reasoning behind the selected one. @mkzie2 feel free to proceed and thanks for understanding with the delay.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 30, 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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Development

No branches or pull requests

7 participants