Skip to content

[HOLD for payment 2024-11-14] [$250] QAB - Error shows up when submitting split distance expense via split manual shortcut in QAB #50694

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: 9.0.48-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh081006@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to group chat (more than 2).
  3. Click + > Split expense > Manual.
  4. Split a manual expense in the group chat.
  5. Click FAB.
  6. Click Split manual under Quick action.
  7. Click Distance.
  8. Submit a split distance expense.

Expected Result:

No error will show up when submitting split distance expense via split manual shortcut in QAB.

Actual Result:

Error shows up when submitting split distance expense via split manual shortcut in QAB.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6633315_1728815023833.20241013_182042.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021845889937723990662
  • Upwork Job ID: 1845889937723990662
  • Last Price Increase: 2024-10-21
  • Automatic offers:
    • Krishna2323 | Contributor | 104666501
Issue OwnerCurrent Issue Owner: @slafortune

Activity

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

    @melvin-bot

    Triggered auto assignment to @slafortune (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 Oct 13, 2024

    @IuliiaHerets
    Author

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

  4. Krishna2323 commented on Oct 13, 2024

    @Krishna2323
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-10-23 09:58:53 UTC.

    Proposal


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

    QAB - Error shows up when submitting split distance expense via split manual shortcut in QAB

    What is the root cause of that problem?

    • The confirmation step is skipped when the request is of any type but the distance request calculations happens on the confirmation.

      if (shouldSkipConfirmation) {
      if (iouType === CONST.IOU.TYPE.SPLIT) {
      IOU.splitBill({
      participants,
      currentUserLogin: currentUserPersonalDetails.login ?? '',
      currentUserAccountID: currentUserPersonalDetails.accountID,
      amount: 0,
      comment: '',
      currency: transaction?.currency ?? 'USD',
      merchant: translate('iou.fieldPending'),
      created: transaction?.created ?? '',
      category: '',
      tag: '',
      billable: false,
      iouRequestType,
      existingSplitChatReportID: report?.reportID,
      });
      return;
      }
      IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD});
      IOU.setMoneyRequestMerchant(transactionID, translate('iou.fieldPending'), false);
      const participant = participants.at(0);
      if (iouType === CONST.IOU.TYPE.TRACK && participant) {
      IOU.trackExpense(
      report,
      0,
      transaction?.currency ?? 'USD',
      transaction?.created ?? '',
      translate('iou.fieldPending'),
      currentUserPersonalDetails.login,
      currentUserPersonalDetails.accountID,
      participant,
      '',
      {},
      '',
      '',
      '',
      0,
      false,
      policy,
      undefined,
      undefined,
      undefined,
      TransactionUtils.getValidWaypoints(waypoints, true),
      undefined,
      undefined,
      undefined,
      undefined,
      customUnitRateID,
      );
      return;
      }
      IOU.createDistanceRequest(
      report,
      participants,
      '',
      transaction?.created ?? '',
      '',
      '',
      '',
      0,
      0,
      transaction?.currency ?? 'USD',
      translate('iou.fieldPending'),
      !!policy?.defaultBillable,
      TransactionUtils.getValidWaypoints(waypoints, true),
      undefined,
      undefined,
      undefined,
      DistanceRequestUtils.getCustomUnitRateID(report.reportID),
      currentUserPersonalDetails.login ?? '',
      currentUserPersonalDetails.accountID,
      transaction?.splitShares,
      iouType,
      );
      return;
      }

    • The calculations happening on the confirmation page:

      useEffect(() => {
      if (isFirstUpdatedDistanceAmount.current) {
      return;
      }
      if (!isDistanceRequest) {
      return;
      }
      const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate ?? 0);
      IOU.setMoneyRequestAmount(transactionID, amount, currency ?? '');
      isFirstUpdatedDistanceAmount.current = true;
      }, [distance, rate, unit, transactionID, currency, isDistanceRequest]);
      useEffect(() => {
      if (!shouldCalculateDistanceAmount) {
      return;
      }
      const amount = distanceRequestAmount;
      IOU.setMoneyRequestAmount(transactionID, amount, currency ?? '');
      // If it's a split request among individuals, set the split shares
      const participantAccountIDs: number[] = selectedParticipantsProp.map((participant) => participant.accountID ?? -1);
      if (isTypeSplit && !isPolicyExpenseChat && amount && transaction?.currency) {
      IOU.setSplitShares(transaction, amount, currency, participantAccountIDs);
      }
      }, [shouldCalculateDistanceAmount, distanceRequestAmount, transactionID, currency, isTypeSplit, isPolicyExpenseChat, selectedParticipantsProp, transaction]);

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


    • We should not skip the confirmation when iouType === CONST.IOU.TYPE.SPLIT is true. if (shouldSkipConfirmation && iouType !== CONST.IOU.TYPE.SPLIT) {.
    • We should also remove this part.
    • OPTIONAL: We can add the split request check here.

    What alternative solutions did you explore? (Optional)

    Result

  5. twilight2294 commented on Oct 14, 2024

    @twilight2294
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-10-21 17:06:08 UTC.

    Proposal

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

    For distance request via split expense for quick actions, we directly create split request instead of distance request and the BE throws error

    What is the root cause of that problem?

    When we create a manual split request, and then from quick actions create a distance request due to shouldSkipConfirmation being true, we create a split request for distance instead of a distance request:

    });
    if (shouldSkipConfirmation) {
    if (iouType === CONST.IOU.TYPE.SPLIT) {
    IOU.splitBill({
    participants,

    Which in turn gives us API error:
    Screenshot 2024-10-14 at 11 38 33 AM

    This is because shouldSkipConfirmation is true For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace:

    // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace
    // request and the workspace requires a category or a tag

    So we never considered the case for group chats, and hence we skip the confirmation step and call the wrong api and get error.

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

    Current shouldSkipConfirmation doesn't consider the case for group chats, so we should add a check that we should not skip the confirmation step when we are on group chat:

    const shouldSkipConfirmation: boolean = useMemo(() => {
    if (!skipConfirmation || !report?.reportID) {
    return false;
    }
    return (
    !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false)))
    );
    }, [report, skipConfirmation, policy, reportNameValuePairs]);

    We should update it to:

    --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx
    +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx
    @@ -114,9 +114,10 @@ function IOURequestStepDistance({
        const shouldSkipConfirmation: boolean = useMemo(() => {
            if (!skipConfirmation || !report?.reportID) {
                return false;
            }
     
             return (
    -            !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false)))
    +            !ReportUtils.isGroupChat(report) && !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false)))
             );
         }, [report, skipConfirmation, policy, reportNameValuePairs]);

    Result Video

    Screen.Recording.2024-10-14.at.11.51.02.AM.mov

    Similar to #47021. The correct solution is to avoid shouldSkipConfirmation=true when moving to a distance request.

    What alternative solutions did you explore? (Optional)

    We should not skip the confirmation through QAB for split expenses, so we should update the following code and set shouldSkipConfirmation to false:

    case CONST.QUICK_ACTIONS.SPLIT_MANUAL:
    selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true), true);
    return;

    case CONST.QUICK_ACTIONS.SPLIT_SCAN:
    selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, true), true);
    return;

                case CONST.QUICK_ACTIONS.SPLIT_MANUAL:
                    selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.MANUAL, false), true);
                    return;
                 case CONST.QUICK_ACTIONS.SPLIT_SCAN:
                    selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, false), true);
                    return;

    Alternative solution 2:

    Like we do on QAB split manual request page, there too shouldSkipConfirmation is true still we do not skip confirmation page because we have the following check that only calls IOU.splitBill when it is a scan request and defaults to confirmation page for manual request:

    if (shouldSkipConfirmation) {
    // Only skip confirmation when the split is not configurable, for now Smartscanned splits cannot be configured
    if (iouType === CONST.IOU.TYPE.SPLIT && transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.SCAN) {
    IOU.splitBill({
    participants,

    We will do the same for distance page as well, update the following:

    if (shouldSkipConfirmation) {
    if (iouType === CONST.IOU.TYPE.SPLIT) {
    IOU.splitBill({

    To:

                if (shouldSkipConfirmation) {
                    // Only skip confirmation when the split is not configurable, for now Smartscanned splits cannot be configured
                    if (iouType === CONST.IOU.TYPE.SPLIT && transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.SCAN) {
                        IOU.splitBill({

    OR

                if (shouldSkipConfirmation && transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.SCAN) {
                    // Only skip confirmation when the split is not configurable, for now Smartscanned splits cannot be configured
                    if (iouType === CONST.IOU.TYPE.SPLIT) {
                        IOU.splitBill({
  6. twilight2294 commented on Oct 14, 2024

    @twilight2294
    Contributor

    @slafortune , you need to be on P2P distance beta to be able to reproduce this bug, let me know if you are not able to reproduce

  7. slafortune commented on Oct 14, 2024

    @slafortune
    Contributor

    Was able to recreate 👍

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 14, 2024
  9. changed the title [-]QAB - Error shows up when submitting split distance expense via split manual shortcut in QAB[/-] [+][$250] QAB - Error shows up when submitting split distance expense via split manual shortcut in QAB[/+] on Oct 14, 2024
  10. melvin-bot commented on Oct 14, 2024

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 14, 2024
  12. 65 remaining items

  13. melvin-bot commented on Nov 7, 2024

    @melvin-bot

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

  14. moved this to Bugs and Follow Up Issues in #expensify-bugson Nov 11, 2024
  15. moved this from Bugs and Follow Up Issues to Hold for Payment in #expensify-bugson Nov 14, 2024
  16. Krishna2323 commented on Nov 19, 2024

    @Krishna2323
    Contributor

    @garrettmknight this one is ready for payments :)

  17. melvin-bot commented on Nov 19, 2024

    @melvin-bot

    @slafortune, @mollfpr, @neil-marcellini, @Krishna2323 Huh... This is 4 days overdue. Who can take care of this?

  18. abekkala commented on Nov 19, 2024

    @abekkala
    Contributor

    Stevies been ooo and returns next week.

    I'll make payment summary

  19. abekkala commented on Nov 19, 2024

    @abekkala
    Contributor

    PAYMENT SUMMARY FOR NOV 14

  20. abekkala commented on Nov 19, 2024

    @abekkala
    Contributor

    @Krishna2323 payment sent and contract ended - thank you! 🎉

  21. moved this from Hold for Payment to Done in #expensify-bugson Nov 19, 2024
  22. garrettmknight commented on Nov 26, 2024

    @garrettmknight
    Contributor

    $250 approved for @mollfpr

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