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

[PAID] [$250] Distance rates - Distance rate order in Rate page is random after clear cache and restart app #50304

Closed
6 tasks done
IuliiaHerets opened this issue Oct 6, 2024 · 30 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 Monthly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 6, 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.45-2
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Distance rates
  3. Add a few distance rates
  4. Go to workspace chat.
  5. Click + > Submit expense > Distance.
  6. Enter waypoints > Next.
  7. Click Rate on confirmation page.
  8. Note that order of distance rates is A, B, C, D, E etc
  9. Go to Troubleshoot > Clear cache and restart
  10. Select Reset and refresh
  11. Repeat Step 4 to 7.

Expected Result:

The order of distance rates in Rate page should remain A, B, C, D, E etc.

Actual Result:

The order of distance rates in Rate page is random after clear cache and restart app.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6625991_1728200705053.20241006_153110.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021844102961422932795
  • Upwork Job ID: 1844102961422932795
  • Last Price Increase: 2024-10-09
  • Automatic offers:
    • paultsimura | Reviewer | 104371732
    • ChavdaSachin | Contributor | 104371734
Issue OwnerCurrent Issue Owner: @CortneyOfstad / @trjExpensify
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 6, 2024
Copy link

melvin-bot bot commented Oct 6, 2024

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

@IuliiaHerets
Copy link
Author

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

@IuliiaHerets
Copy link
Author

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

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Oct 6, 2024

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

Proposal

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

Distance rate order in Rate page is random after clear cache and restart app

What is the root cause of that problem?

We are not sorting distanceRates here.

const rates = DistanceRequestUtils.getMileageRates(policy, false, currentRateID);

While we do sort rates on PolicyDistanceRatesPage here.

const distanceRatesList = useMemo<RateForList[]>(
() =>
Object.values(customUnitRates)
.sort((rateA, rateB) => (rateA?.rate ?? 0) - (rateB?.rate ?? 0))
.map((value) => ({

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

Implement sorting after reading rates from ONYX here.

const rates = DistanceRequestUtils.getMileageRates(policy, false, currentRateID);

Implement sorting similar to PolicyDistanceRatesPage

What alternative solutions did you explore? (Optional)

Alternatively we could implement sorting in getMileageRates function here instead of sorting on IOURequestStemDistancePage.

function getMileageRates(policy: OnyxInputOrEntry<Policy>, includeDisabledRates = false, selectedRateID?: string): Record<string, MileageRate> {

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@cretadn22
Copy link
Contributor

Proposal

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

Distance rate order in Rate page is random after clear cache and restart app

What is the root cause of that problem?

We don't currently sort the distance rate list in IOURequestStepDistanceRate.

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 : '',

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

We need to sort the distance rate list in IOURequestStepDistanceRate, similar to how it's done in PolicyDistanceRatesPage.

.sort((rateA, rateB) => (rateA?.rate ?? 0) - (rateB?.rate ?? 0))

What alternative solutions did you explore? (Optional)

@ChavdaSachin
Copy link
Contributor

Updated Proposal

Updated Proposal added alternate solution.

@cretadn22
Copy link
Contributor

Note for the reviewer:

  1. My proposal provides the correct sorting function first (using the same approach as in PolicyDistanceRatesPage). @ChavdaSachin had the same idea but made his update after I submitted my proposal

  2. Bringing the sorting logic into the getMileageRates function has no impact. It’s more complicated than my proposal but doesn’t offer any additional benefits

@ChavdaSachin
Copy link
Contributor

@cretadn22 thanks for your insights,
But I believe Proposals are about sharing ideas how a problem could be solved isn't it?
And I believe sorting is not any sort of complex problem where it's must to share pseudo code to make reviewer believe in your solution.
But anyways I will respect whatever thought reviewer might have.

@nkdengineer
Copy link
Contributor

Proposal

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

The order of distance rates in Rate page is random after clear cache and restart app.

What is the root cause of that problem?

I notice that other proposals aren't clear why the display rate is different when we reset cache and restart

When we add new distances, these objects are added to Onyx in turn then this displays the current order that we added is A, B, C, D, E

const sections = Object.values(rates).map((rate) => {

After we reset the cache and restarted, BE returned another order of rates object then it displayed in a different order

const sections = Object.values(rates).map((rate) => {

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

Sort the distance rates by rate value as we do here

const sections = Object.values(rates)
        .sort((rateA, rateB) => (rateA.rate ?? 0) - (rateB.rate ?? 0))
        .map((rate) => {

const sections = Object.values(rates).map((rate) => {
const rateForDisplay = DistanceRequestUtils.getRateForDisplay(rate.unit, rate.rate, rate.currency, translate, toLocaleDigit);

What alternative solutions did you explore? (Optional)

NA

@melvin-bot melvin-bot bot added the Overdue label Oct 8, 2024
Copy link

melvin-bot bot commented Oct 9, 2024

@CortneyOfstad Whoops! This issue is 2 days overdue. Let's get this updated quick!

@CortneyOfstad CortneyOfstad added the External Added to denote the issue can be worked on by a contributor label Oct 9, 2024
@melvin-bot melvin-bot bot changed the title Distance rates - Distance rate order in Rate page is random after clear cache and restart app [$250] Distance rates - Distance rate order in Rate page is random after clear cache and restart app Oct 9, 2024
Copy link

melvin-bot bot commented Oct 9, 2024

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

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

melvin-bot bot commented Oct 9, 2024

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

@CortneyOfstad
Copy link
Contributor

@paultsimura we have a few proposals above for you to review when you have a chance — thanks!

@paultsimura
Copy link
Contributor

Thanks, I'll review soon 👀

@paultsimura
Copy link
Contributor

Thanks for the proposals, everyone. Considering the triviality of the sorting mechanism here, all 3 proposals look essentially the same to me.
Therefore, I would go with the first one by @ChavdaSachin.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 9, 2024

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

@cretadn22
Copy link
Contributor

cretadn22 commented Oct 10, 2024

This was @ChavdaSachin's initial proposal, and they updated it after mine.

22

@paultsimura Do you think this is enough for a proposal? It doesn't mention how we sort the list. While the issue is straightforward, it's clear the problem is the lack of a sort function and I believe the proposal need to outline how we sort the list. This is the main key point we need to find out instead of only say "implement sorting"

@paultsimura
Copy link
Contributor

Yes @cretadn22 – I've checked the initial version of that proposal, and it directs to the file with missing sorting, it also suggests what data we need to sort.
As I've mentioned in my review, the sorting itself is quite straightforward, so the first version of that proposal was enough for me.

I'll leave the rest of the consideration for @madmax330 though.

@madmax330
Copy link
Contributor

I agree with @paultsimura, I don't how we're sorting the data is the most important part of the proposal.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Oct 14, 2024
@CortneyOfstad CortneyOfstad removed their assignment Oct 15, 2024
@CortneyOfstad CortneyOfstad added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 15, 2024
@CortneyOfstad CortneyOfstad self-assigned this Oct 15, 2024
@CortneyOfstad
Copy link
Contributor

Hey @trjExpensify! I am heading OoO this afternoon (10/15 to 10/23) so reassigning to keep this moving! The PR here has not been launched to staging just yet 👍

Thanks!

@trjExpensify
Copy link
Contributor

Sounds good!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Oct 18, 2024
@melvin-bot melvin-bot bot changed the title [$250] Distance rates - Distance rate order in Rate page is random after clear cache and restart app [HOLD for payment 2024-10-25] [$250] Distance rates - Distance rate order in Rate page is random after clear cache and restart app Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.50-8 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-10-25. 🎊

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

Copy link

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

@paultsimura
Copy link
Contributor

This can be treated as a feature request.

  • The PR that introduced the bug has been identified. Link to the PR: N/A
  • 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: N/A
  • 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: N/A
  • Determine if we should create a regression test for this bug: Yes
  • 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.

Regression Test Proposal

Note: This is a beta feature, so enable canUseP2PDistanceRequests beta before proceeding.

  1. Go to workspace settings > Distance rates
  2. Add a few distance rates
  3. Verify they are sorted based on the rate values in ascending order.
  4. Go to a workspace chat.
  5. Click + > Submit expense > Distance.
  6. Enter waypoints > Next.
  7. Click Rate on the confirmation page.
  8. Verify that the Distance rates are sorted based on the rate values in ascending order.
  9. Submit the request
  10. Navigate to the request details page
  11. Click "Rate" to open the rate editor
  12. Verify that the Distance rates are always sorted based on the rate values in ascending order.

Do we agree 👍 or 👎

@CortneyOfstad
Copy link
Contributor

I'm back from OoO — thanks for holding down the fort @trjExpensify!

Agree with your proposal @paultsimura!

@melvin-bot melvin-bot bot added Daily KSv2 Monthly KSv2 and removed Weekly KSv2 labels Oct 25, 2024
@CortneyOfstad
Copy link
Contributor

Payment Summary

@paultsimura — paid $250 via Upwork
@ChavdaSachin — paid $250 via Upwork

Regression Test

https://github.com/Expensify/Expensify/issues/439059

@github-project-automation github-project-automation bot moved this from LOW to Done in [#whatsnext] #quality Oct 25, 2024
@CortneyOfstad CortneyOfstad changed the title [HOLD for payment 2024-10-25] [$250] Distance rates - Distance rate order in Rate page is random after clear cache and restart app [PAID] [$250] Distance rates - Distance rate order in Rate page is random after clear cache and restart app Oct 25, 2024
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 Monthly KSv2
Projects
Development

No branches or pull requests

8 participants