-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[C+ Checklist Needs Completion] [$250] Distance rates - Order of distance rates is not preserved after clearing cache and restarting #42939
Comments
Triggered auto assignment to @greg-schroeder ( |
@greg-schroeder 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 |
We think that this bug might be related to #wave-collect - Release 1 |
ProposalPlease re-state the problem that we are trying to solve in this issue.Distance rates - Order of distance rates is not preserved after clearing cache and restarting What is the root cause of that problem?We don't sort the App/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx Lines 101 to 116 in d5ca2a7
What changes do you think we should make in order to solve the problem?We can sort the list by the If we decide to sort it by the text then we can add: .sort((a, b) => localeCompare(a.text, b.text)) ?? [] If we decide to sort by the rate then we can simply add rate property in each object and then sort: const distanceRatesList = useMemo<RateForList[]>(
() =>
Object.values(customUnitRates)
.map((value) => ({
value: value.customUnitRateID ?? '',
rate: value.rate ?? 0,
text: `${CurrencyUtils.convertAmountToDisplayString(value.rate, value.currency ?? CONST.CURRENCY.USD)} / ${translate(
`common.${customUnit?.attributes?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES}`,
)}`,
keyForList: value.customUnitRateID ?? '',
isSelected: selectedDistanceRates.find((rate) => rate.customUnitRateID === value.customUnitRateID) !== undefined,
isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
pendingAction: value.pendingAction ?? value.pendingFields?.rate ?? value.pendingFields?.enabled ?? value.pendingFields?.currency,
errors: value.errors ?? undefined,
rightElement: <ListItemRightCaretWithLabel labelText={value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} />,
}))
.sort((a, b) => a.rate - b.rate) ?? [],
[customUnit?.attributes?.unit, customUnitRates, selectedDistanceRates, translate],
); We can also sort in descending order and with any suggested field. What alternative solutions did you explore? (Optional) |
Job added to Upwork: https://www.upwork.com/jobs/~0149693392cec4578c |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @allroundexperts ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Order of distance rates is not preserved after clearing cache and restarting What is the root cause of that problem?We haven't yet applied the sorting algorithm to the distance rate page App/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx Lines 101 to 105 in 0cb2dc0
What changes do you think we should make in order to solve the problem?App/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx Lines 101 to 105 in 0cb2dc0
we should sort distance rate by rate field, we must sort them beforehand as the rate field is not included in the distanceRatesList, ensuring sorting is done prior to the map function.
We shouldn't include a rate field in the returned value as suggested earlier, as it serves no purpose. What alternative solutions did you explore? (Optional) |
Proposals under review |
ProposalPlease re-state the problem that we are trying to solve in this issue.Distance rates - Order of distance rates is not preserved after clearing cache and restarting What is the root cause of that problem?New change. As of now, there's no sorting mechanism in App/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx Lines 101 to 116 in 0cb2dc0
What changes do you think we should make in order to solve the problem?Use the below logic to sort on the basis of text, while keeping the enabled ones first.
|
ProposalPlease re-state the problem that we are trying to solve in this issue.The order of distance rates is no longer A, B, C, D, E etc What is the root cause of that problem?In
distanceRatesList in any order, so when clearing the cache, the list order will change.
What changes do you think we should make in order to solve the problem?We should sort the There're 2 ways to do this:
Optionally, we can additionally sort by What alternative solutions did you explore? (Optional)NA |
ProposalPlease re-state the problem that we are trying to solve in this issue.Order of What is the root cause of that problem?There is no order defined for displaying distance rates in the list view. As the code uses Creation of map: Display of distance rates: When cache is cleared, the What changes do you think we should make in order to solve the problem?Sort order of displaying distance rates in the UI should be independent of the datastructure used underneath. Propose to define one of the following sort orders.
The above order must be preserved using a property in the Hnece this bug needs implementation in both backend and frontend. Propose to split this into backend and frontend separately or make it as What alternative solutions did you explore? (Optional)N.A. |
Thanks for the proposals everyone. Since this is a straightforward issue, with the solution being almost the same across all the proposals, I'd suggest we go with the first proposal that mentions sorting. As such, @Krishna2323's proposal looks good to me. 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @tgolen, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
I think it would be nice to have enabled options at the top. My proposal includes that. |
@ShridharGoel It's still the same idea. I think we can handle it in the PR if needed. |
@allroundexperts I think it's important that the solution being applied results in the best possible UX for the user.
If we evaluate based on this, we might end up with an arbitrary sorting that's not ideal for the user. It satisfies the "mentions sorting" part of the criteria, but far from the best we can do. I.e. If we decide to go with "sorting by created date" similar to OldDot, the proposal being selected will not work because the Curious what @tgolen thinks too! |
That's correct, but we really did not specify "What the sorting criteria should be" in the bug statement. As such, you're just throwing a guess on the best sorting criteria. In my opinion, its a little unfair to the first proposer as the new proposals are suggesting the same thing with different sort criteria. |
@allroundexperts : I agree with your statement regarding the fairness part to the first proposer. But if you look at this bug, it indeed is about sorting. However, what also needs to be looked into is the thought that others have put behind while proposing the same sorting solution. @dominictb : what do you think about the suggestions in this proposal? |
@allroundexperts I'd say "give the best suggestion based on experience and investigation" instead of "throwing a guess". In my case I also looked up how we did it/implemented it in OldDot to give the suggestion.
@allroundexperts Different sorting criteria will require different implementations, in my suggestion it also requires back-end change. As such, do you agree that a proposal that just mentions "sorting at this block in the front-end code" would not suffice as a complete solution, if we end up deciding to sort by |
@allroundexperts : sorting based on |
Not overdue. We're still finalising the best sorting criteria. @tgolen Can you please check @Krishna2323's comment above? |
OK, thanks. Let's go with your recommendation then for now. |
Will raise PR today. |
@allroundexperts, PR ready for review. |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.85-7 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-06-28. 🎊 For reference, here are some details about the assignees on this issue:
|
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:
|
@allroundexperts - $250 - You can make a manual request via ND |
C+ checklist is all we need for tomorrow and we can close! |
@tgolen @greg-schroeder @allroundexperts @Krishna2323 this issue is now 4 weeks old, please consider:
Thanks! |
Checklist
|
Okay filing using OP steps |
$250 approved for @allroundexperts |
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: 1.4.78-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
The order of distance rates will remain as A, B, C, D, E etc
Actual Result:
The order of distance rates is no longer A, B, C, D, E etc
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6497628_1717166582761.20240531_223747.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @greg-schroederThe text was updated successfully, but these errors were encountered: