Skip to content

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

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.45-2
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh0410007@applause.expensifail.com
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

Activity

  1. added
    Daily
    Bug
    on Oct 6, 2024
  2. melvin-bot commented on Oct 6, 2024

    @melvin-bot

    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.

  3. IuliiaHerets commented on Oct 6, 2024

    @IuliiaHerets
    Author

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

  4. IuliiaHerets commented on Oct 6, 2024

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

  5. ChavdaSachin commented on Oct 6, 2024

    @ChavdaSachin
    Contributor

    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.

  6. cretadn22 commented on Oct 6, 2024

    @cretadn22
    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)

  7. ChavdaSachin commented on Oct 6, 2024

    @ChavdaSachin
    Contributor

    Updated Proposal

    Updated Proposal added alternate solution.

  8. cretadn22 commented on Oct 6, 2024

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

  9. ChavdaSachin commented on Oct 6, 2024

    @ChavdaSachin
    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.

  10. nkdengineer commented on Oct 7, 2024

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

  11. melvin-bot commented on Oct 9, 2024

    @melvin-bot

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

  12. added
    External
    on Oct 9, 2024
  13. 35 remaining items

  14. added
    Awaiting Payment
    on Oct 18, 2024
  15. 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[/+] on Oct 18, 2024
  16. melvin-bot commented on Oct 18, 2024

    @melvin-bot

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

  17. removed
    Reviewing
    on Oct 18, 2024
  18. melvin-bot commented on Oct 18, 2024

    @melvin-bot

    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:

  19. melvin-bot commented on Oct 18, 2024

    @melvin-bot

    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:
  20. paultsimura commented on Oct 21, 2024

    @paultsimura
    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 👎

  21. CortneyOfstad commented on Oct 24, 2024

    @CortneyOfstad
    Contributor

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

    Agree with your proposal @paultsimura!

  22. added
    Daily
    and removed
    Weekly
    on Oct 25, 2024
  23. CortneyOfstad commented on Oct 25, 2024

    @CortneyOfstad
    Contributor

    Payment Summary

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

    Regression Test

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

  24. 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[/+] on Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalMonthly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions