Skip to content

[HOLD for payment 2024-07-26] [$250] [Hold] Distance rates- Deleted distance rate is not disabled when submitting distance expense offline #44154

Closed

Description

@lanitochka17

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.0-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4652159
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Workspace has a few distance rates
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Distance rates
  3. Go offline
  4. Delete one of the distance rates
  5. Go to workspace chat
  6. Submit a distance expense with the deleted distance rate
  7. Go online

Expected Result:

In Step 6, app should prevent the deleted distance rate from being selected when submitting a distance distance

Actual Result:

In Step 6, user can submit a distance expense with the deleted distance rate, which results in error when returning online

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

Bug6520132_1718947996614.20240621_132706.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ad6ccc1c574e1a03
  • Upwork Job ID: 1810478926161920694
  • Last Price Increase: 2024-07-09
  • Automatic offers:
    • shubham1206agra | Reviewer | 103049061
    • paultsimura | Contributor | 103049063
Issue OwnerCurrent Issue Owner: @OfstadC

Activity

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

    @melvin-bot

    Triggered auto assignment to @OfstadC (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. lanitochka17 commented on Jun 21, 2024

    @lanitochka17
    Author

    @OfstadC 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. lanitochka17 commented on Jun 21, 2024

    @lanitochka17
    Author

    We think that this bug might be related to #wave-collect - Release 1

  5. bernhardoj commented on Jun 21, 2024

    @bernhardoj
    Contributor

    Proposal

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

    We can still select pending-delete distance rate and will result in an error when submitted.

    What is the root cause of that problem?

    We are not filtering any distance rate that is pending-delete when showing the rate list.

    const sections = Object.values(rates).map((rate) => {
    const rateForDisplay = DistanceRequestUtils.getRateForDisplay(rate.unit, rate.rate, rate.currency, translate, toLocaleDigit);
    return {
    text: rate.name ?? rateForDisplay,
    alternateText: rate.name ? rateForDisplay : '',
    keyForList: rate.customUnitRateID,
    value: rate.customUnitRateID,
    isSelected: lastSelectedRateID ? lastSelectedRateID === rate.customUnitRateID : !!(rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE),
    };
    });

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

    Filter out any pending-delete rate. To do that:

    1. Return the pendingAction from getMileageRates
      mileageRates[rateID] = {
      rate: rate.rate,
      currency: rate.currency,
      unit: distanceUnit.attributes.unit,
      name: rate.name,
      customUnitRateID: rate.customUnitRateID,
      };

    pendingAction: rate.pendingAction,

    1. Filter out rate with pending action of delete.
      const sections = Object.values(rates).map((rate) => {

      .filter(rate => rate.pendingAction !== 'delete')
  6. Krishna2323 commented on Jun 21, 2024

    @Krishna2323
    Contributor

    Proposal

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

    Distance rates- Deleted distance rate is not disabled when submitting distance expense offline

    What is the root cause of that problem?

    We don't have any check for disabled rates on IOURequestStepDistanceRate page.

    const sections = Object.values(rates).map((rate) => {
    const rateForDisplay = DistanceRequestUtils.getRateForDisplay(rate.unit, rate.rate, rate.currency, translate, toLocaleDigit);
    return {
    text: rate.name ?? rateForDisplay,
    alternateText: rate.name ? rateForDisplay : '',
    keyForList: rate.customUnitRateID,
    value: rate.customUnitRateID,
    isSelected: lastSelectedRateID ? lastSelectedRateID === rate.customUnitRateID : !!(rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE),
    };
    });

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

    We need to first return pendingAction field from getMileageRates.

            mileageRates[rateID] = {
                rate: rate.rate,
                currency: rate.currency,
                unit: distanceUnit.attributes.unit,
                name: rate.name,
                customUnitRateID: rate.customUnitRateID,
                pendingAction: rate.pendingAction,
            };

    Then add isDisabled and pendingAction.

            return {
                text: rate.name ?? rateForDisplay,
                alternateText: rate.name ? rateForDisplay : '',
                keyForList: rate.customUnitRateID,
                value: rate.customUnitRateID,
                isSelected: lastSelectedRateID ? lastSelectedRateID === rate.customUnitRateID : !!(rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE),
                isDisabled: rate.pendingAction === 'delete',
                pendingAction: rate.pendingAction,
            };

    What alternative solutions did you explore? (Optional)

    If we also need to grey out the option when updated offline, we nee to also return pendingFields from getMileageRates and update the pendingAction property like we do in PolicyDistanceRatesPage.

    pendingAction:
    value.pendingAction ??
    value.pendingFields?.rate ??
    value.pendingFields?.enabled ??
    value.pendingFields?.currency ??
    (policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? policy?.pendingAction : undefined),

        const sections = Object.values(rates).map((rate) => {
            const rateForDisplay = DistanceRequestUtils.getRateForDisplay(rate.unit, rate.rate, rate.currency, translate, toLocaleDigit);
    
            return {
                text: rate.name ?? rateForDisplay,
                alternateText: rate.name ? rateForDisplay : '',
                keyForList: rate.customUnitRateID,
                value: rate.customUnitRateID,
                isSelected: lastSelectedRateID ? lastSelectedRateID === rate.customUnitRateID : !!(rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE),
                isDisabled: rate.pendingAction === 'delete',
                pendingAction:
                    rate.pendingAction ??
                    rate.pendingFields?.rate ??
                    rate.pendingFields?.enabled ??
                    rate.pendingFields?.currency ??
                    (policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? policy?.pendingAction : undefined),
            };
        });
  7. Krishna2323 commented on Jun 21, 2024

    @Krishna2323
    Contributor

    Proposal Updated

    • Removed redundant code.
  8. Krishna2323 commented on Jun 21, 2024

    @Krishna2323
    Contributor

    Proposal Updated

    • We also need to add pendingAction: rate.pendingAction for correct styling.
  9. Krishna2323 commented on Jun 21, 2024

    @Krishna2323
    Contributor

    Proposal Updated

    • Added alternative
  10. OfstadC commented on Jun 21, 2024

    @OfstadC
    Contributor

    Following this Slack thread before proceeding

  11. OfstadC commented on Jun 24, 2024

    @OfstadC
    Contributor

    @mallenexpensify I wonder if the Offline Distance request issues should be consolidated since they might have the same/similar solution? 🤔

  12. 47 remaining items

  13. OfstadC commented on Jul 26, 2024

    @OfstadC
    Contributor

    Payment Summary:

  14. shubham1206agra commented on Jul 26, 2024

    @shubham1206agra
    Contributor

    @OfstadC Offer accepted

  15. mallenexpensify commented on Jul 26, 2024

    @mallenexpensify
    Contributor

    @shubham1206agra paid via Upwork, payment confirmation updated above. @shubham1206agra plz complete the BZ checklist above.

  16. melvin-bot commented on Jul 29, 2024

    @melvin-bot

    @arosiclair, @OfstadC, @paultsimura, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. arosiclair commented on Jul 30, 2024

    @arosiclair
    Contributor

    @shubham1206agra I think you still need to complete the checklist

  18. shubham1206agra commented on Jul 30, 2024

    @shubham1206agra
    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:

  19. mallenexpensify commented on Jul 30, 2024

    @mallenexpensify
    Contributor

    @shubham1206agra do we want a test case for this? If so, please provide the steps. If not, please provide reasoning why not. Thx

  20. shubham1206agra commented on Jul 31, 2024

    @shubham1206agra
    Contributor

    @mallenexpensify We don't need any test steps here as this was an edge case that we missed during initial implementation, and the bug should not happen again in future.

  21. melvin-bot commented on Jul 31, 2024

    @melvin-bot

    @arosiclair, @OfstadC, @paultsimura, @shubham1206agra Huh... This is 4 days overdue. Who can take care of this?

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