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

[$500] Send money - Pay elsewhere appears for second on send money #29311

Closed
6 tasks done
kbecciv opened this issue Oct 11, 2023 · 9 comments
Closed
6 tasks done

[$500] Send money - Pay elsewhere appears for second on send money #29311

kbecciv opened this issue Oct 11, 2023 · 9 comments
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

@kbecciv
Copy link

kbecciv commented Oct 11, 2023

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:
Reproducible in staging?:
Reproducible in production?:
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:
Slack conversation:

Action Performed:

  1. Click on FAB and select send money
  2. Enter amount and select user
  3. Send money

Expected Result:

It should not show Pay elsewhere button

Actual Result:

Pay elsewhere appears for second

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

Android: Native

https://github.com/Expensify/App/assets/93399543/f9906108-1a3a-4f5d-943d-96957585e28

Android: mWeb Chrome
Screen_Recording_20231011_123219_Chrome.mp4
iOS: Native
Simulator.Screen.Recording.-.iPhone.13.-.2023-10-11.at.14.01.33.mp4
iOS: mWeb Safari
RPReplay_Final1697008039.MP4
MacOS: Chrome / Safari
Screen.Recording.2023-10-11.at.11.56.55.AM.mov
Recording.4944.mp4
MacOS: Desktop
Screen.Recording.2023-10-11.at.12.50.09.PM.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012a35d1f8510e892f
  • Upwork Job ID: 1712095218580516864
  • Last Price Increase: 2023-10-11
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 11, 2023
@melvin-bot melvin-bot bot changed the title Send money - Pay elsewhere appears for second on send money [$500] Send money - Pay elsewhere appears for second on send money Oct 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

Triggered auto assignment to @zanyrenney (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

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

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

melvin-bot bot commented Oct 11, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

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

@suneox
Copy link
Contributor

suneox commented Oct 11, 2023

Proposal

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

Send money - Pay elsewhere appears for second on send money

What is the root cause of that problem?

we have condition to show Pay elsewhere button at here and it belong to iouSettled at here but when data loading inside function report metadata is not ready so iouSettled is false then Pay elsewhere will display util report is loaded

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

At ReportPreview component we can subscribe loading status

export default compose(
    withLocalize,
    withOnyx({
        ...
+       reportMetadata: {
+           key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`,
+           initialValue: {
+               isLoadingReportActions: true,
+               isLoadingMoreReportActions: false,
+           },
+       },
    }),
)(ReportPreview);

and set props type for reportMetadata
then we can check condition before render button at here

  {!props.reportMetadata.isLoadingReportActions && shouldShowSettlementButton && (
      <SettlementButton

What alternative solutions did you explore? (Optional)

Instead of checking the condition to render we can apply the loading state

  {props.reportMetadata.isLoadingReportActions ? (
      <ActivityIndicator
          color={themeColors.spinner}
          size="large"
          style={StyleSheet.absoluteFill}
      />
  ) : (
      shouldShowSettlementButton && (
          <SettlementButton
              currency={props.iouReport.currency}
              policyID={props.policyID}
              chatReportID={props.chatReportID}
              iouReport={props.iouReport}
              onPress={(paymentType) => IOU.payMoneyRequest(paymentType, props.chatReport, props.iouReport)}
              enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
              addBankAccountRoute={bankAccountRoute}
              style={[styles.requestPreviewBox]}
              anchorAlignment={{
                  horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
                  vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
              }}
          />
      )
  )}
29311.mp4

if we have any loading pattern in this case we can apply it

@alitoshmatov
Copy link
Contributor

alitoshmatov commented Oct 11, 2023

Proposal

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

Send money - Pay elsewhere appears for second on send money

What is the root cause of that problem?

When sending money optimistic data should show that this payment is already completed, but it is not doing that. That is why initially Pay elsewhere button occurs until response is received from backend which sets report status as paid.
Screenshot 2023-10-11 at 22 06 31

I think send money logic was different before, paying to send money request was separate action than creating send money itself. That is why we have this problem.

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

We should update optimistic data here to include statusNum=4 when isSendingMoney true

App/src/libs/ReportUtils.js

Lines 2119 to 2122 in 8c73c2b

state: CONST.REPORT.STATE.SUBMITTED,
stateNum: isSendingMoney ? CONST.REPORT.STATE_NUM.SUBMITTED : CONST.REPORT.STATE_NUM.PROCESSING,
total,

statusNum corresponds to payment status and is checked here to show Settlement button
const shouldShowSettlementButton = ReportUtils.isControlPolicyExpenseChat(props.chatReport)
? props.policy.role === CONST.POLICY.ROLE.ADMIN && ReportUtils.isReportApproved(props.iouReport) && !iouSettled && !iouCanceled
: !_.isEmpty(props.iouReport) && isCurrentUserManager && !isReportDraft && !iouSettled && !iouCanceled && !props.iouReport.isWaitingOnBankAccount && reportTotal !== 0;

What alternative solutions did you explore? (Optional)

@AmjedNazzal
Copy link
Contributor

Proposal

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

Send money - Pay elsewhere appears for second on send money

What is the root cause of that problem?

When we are using IOU.sendMoneyElsewhere, we are getting optimisticData from getSendMoneyParams which returns optemisticData that doesn't include statusNum in it, so when we are checking isSettled inside ReportUtils.isSettled we are expecting report.statusNum to be initially ready and have REPORT.STATUS.REIMBURSED as it's value to decide that it indeed is settled but it will not be as we are not writing it in sendMoneyElsewhere

App/src/libs/ReportUtils.js

Lines 277 to 286 in f557852

function isSettled(reportID) {
if (!allReports) {
return false;
}
const report = allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] || {};
if ((typeof report === 'object' && Object.keys(report).length === 0) || report.isWaitingOnBankAccount) {
return false;
}
return report.statusNum === CONST.REPORT.STATUS.REIMBURSED;

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

Since sendMoneyElsewhere will always mean that the user is sending money elsewhere it will be always settles so we can include that in the optemisticData to make sure it's readily available, we can do that by passing statusNum to getSendMoneyParams and adding it there to the optimisticIOUReportData

function sendMoneyElsewhere(report, amount, currency, comment, managerID, recipient) {
    const statusNum =  CONST.REPORT.STATUS.REIMBURSED;
    const {params, optimisticData, successData, failureData} = getSendMoneyParams(report, amount, currency, comment, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, managerID, recipient, statusNum);
const optimisticIOUReportData = {
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticIOUReport.reportID}`,
    value: {
        ...optimisticIOUReport,
        lastMessageText: optimisticIOUReportAction.message[0].text,
        lastMessageHtml: optimisticIOUReportAction.message[0].html,
        statusNum: statusNum,
    },
};

Result

Screen.Recording.2023-10-11.at.8.13.26.PM.mov

@hoangzinh
Copy link
Contributor

@suneox @alitoshmatov @AmjedNazzal Thanks for proposals, everyone. I appreciate it. But it seems this issue has been fixed in #29358. I couldn't reproduce this bug in the latest main.

@melvin-bot melvin-bot bot added the Overdue label Oct 16, 2023
@zanyrenney
Copy link
Contributor

I also can't reproduce, so based off that and the linked issue above, closing!

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
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
None yet
Development

No branches or pull requests

6 participants