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 2024-07-26] [$250] [Hold] Distance rates- Deleted distance rate is not disabled when submitting distance expense offline #44154

Closed
6 tasks done
lanitochka17 opened this issue Jun 21, 2024 · 45 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 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jun 21, 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.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
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

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.

@lanitochka17
Copy link
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

@lanitochka17
Copy link
Author

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

@bernhardoj
Copy link
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')

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jun 21, 2024

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),
        };
    });

@Krishna2323
Copy link
Contributor

Proposal Updated

  • Removed redundant code.

@Krishna2323
Copy link
Contributor

Proposal Updated

  • We also need to add pendingAction: rate.pendingAction for correct styling.

@Krishna2323
Copy link
Contributor

Proposal Updated

  • Added alternative

@OfstadC
Copy link
Contributor

OfstadC commented Jun 21, 2024

Following this Slack thread before proceeding

@melvin-bot melvin-bot bot added the Overdue label Jun 24, 2024
@OfstadC
Copy link
Contributor

OfstadC commented Jun 24, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Jun 24, 2024
@mallenexpensify
Copy link
Contributor

Asking about consolidating, should have an update tomorrow 🤞

@OfstadC
Copy link
Contributor

OfstadC commented Jun 26, 2024

Thanks Matt!

@OfstadC
Copy link
Contributor

OfstadC commented Jun 27, 2024

Any update @mallenexpensify ? 😃

@mallenexpensify
Copy link
Contributor

@paultsimura can you please comment so I can assign to you?
Created a tracking issue for 'offline distance' issues.

@mallenexpensify mallenexpensify changed the title Distance rates- Deleted distance rate is not disabled when submitting distance expense offline [Hold] Distance rates- Deleted distance rate is not disabled when submitting distance expense offline Jun 28, 2024
@paultsimura
Copy link
Contributor

👋🏼

@melvin-bot melvin-bot bot added the Overdue label Jul 1, 2024
@OfstadC
Copy link
Contributor

OfstadC commented Jul 1, 2024

@mallenexpensify Is there any action I need to take here?

@melvin-bot melvin-bot bot removed the Overdue label Jul 1, 2024
@mallenexpensify
Copy link
Contributor

No @OfstadC , @paultsimura is going to to plan to holistically address offline distance bugs. He'll comment here with an update once he's reviewed all issues (and either raise a PR or recommend making the issue external)

@melvin-bot melvin-bot bot added the Overdue label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 4, 2024

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

@paultsimura
Copy link
Contributor

@mallenexpensify I have a quite simple fix for this – if I put up a PR, who's going to be the reviewer?

Copy link

melvin-bot bot commented Jul 9, 2024

📣 @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 Jul 9, 2024

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

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jul 10, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 19, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Hold] Distance rates- Deleted distance rate is not disabled when submitting distance expense offline [HOLD for payment 2024-07-26] [$250] [Hold] Distance rates- Deleted distance rate is not disabled when submitting distance expense offline Jul 19, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 19, 2024
Copy link

melvin-bot bot commented Jul 19, 2024

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

Copy link

melvin-bot bot commented Jul 19, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.9-5 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 2024-07-26. 🎊

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

Copy link

melvin-bot bot commented Jul 19, 2024

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:

  • [@paultsimura / @shubham1206agra] The PR that introduced the bug has been identified. Link to the PR:
  • [@paultsimura / @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:
  • [@paultsimura / @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:
  • [@paultsimura / @shubham1206agra] Determine if we should create a regression test for this bug.
  • [@paultsimura / @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.
  • [@OfstadC] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@OfstadC
Copy link
Contributor

OfstadC commented Jul 26, 2024

@shubham1206agra I think you may need to accept the offer in Upwork? It's not showing an option to Approve payment

@OfstadC
Copy link
Contributor

OfstadC commented Jul 26, 2024

Payment Summary:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 26, 2024
@shubham1206agra
Copy link
Contributor

@OfstadC Offer accepted

@mallenexpensify
Copy link
Contributor

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

@melvin-bot melvin-bot bot added the Overdue label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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

@arosiclair
Copy link
Contributor

@shubham1206agra I think you still need to complete the checklist

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

@mallenexpensify
Copy link
Contributor

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

@shubham1206agra
Copy link
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.

Copy link

melvin-bot bot commented Jul 31, 2024

@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
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Status: Done
Development

No branches or pull requests

8 participants