Closed IuliiaHerets closed 1 month ago
Triggered auto assignment to @isabelastisser (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.
@isabelastisser 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
Incorrect list value editor opens after renaming the list value
We currently navigate to the report field value page using the index value. However, when we update the report field value, the order of the report field list changes, which also alters the index of the current value.
We should indicate the report value page (setting page, edit name page,....) by its name rather than its index value. Hereβs what we need to do:
List value B opens after renaming list value C to A.
We have an error with method Onyx.merge
here, it will merge in alphabetical order
Onyx when merging list like ['c', 'a', 'b'] it saves as ['a', 'b', 'c']
We should display based on field name rather than index value by
fieldName
instead of valueIndex
ReportFieldsAddListValuePage
, ReportFieldsEditValuePage
, ReportFieldsValueSettingsPage
to use fieldName
paramsfieldName
Simply, we can recalculate the valueIndex
in here base on LIST_VALUES
and currentFieldName
to navigate to correct route when we edit done
Job added to Upwork: https://www.upwork.com/jobs/~021837218246278248735
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane (External
)
@cretadn22 is there some sort of ID that we can use instead of name to navigate?
please see what data we have available for the Onyx key
@rushatgabhane When creating the report field list, we store the draft data in workspaceReportFieldForm, and I don't see any additional IDs.
c+ reviewed @cretadn22's proposal https://github.com/Expensify/App/issues/49546#issuecomment-2364310663
πππ
Triggered auto assignment to @johnmlee101, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@cretadn22 let's use newName and oldName to set optimistic / success and failure data
Report fields - Incorrect list value editor opens after renaming the list value
With introduction of https://github.com/Expensify/react-native-onyx/pull/567, we started to use shared connection value. But in
we have used in place sorting which fools the values order when merging here https://github.com/Expensify/App/blob/513e6b3c714adbe24cd8b88c9fc9c20130a6c9d4/src/libs/actions/Policy/ReportField.ts#L101-L104 which make it look like it merged alphabetically due to shared value system in Onyx, it will sort every instance that uses listValues since variable reference never changed.
Onyx when merging list like ['c', 'a', 'b']
, it looks like it saved as ['a', 'b', 'c']
We will use a copy instead here
const listValues = [...(formDraft?.[INPUT_IDS.LIST_VALUES] ?? [])].sort(localeCompare).join(', ');
So it will perform in place sorting on a copy instead
NA
@rushatgabhane You may need to re-evaluate your decision.
I think both solutions would work.
Routes based on index is a bit fragile, don't you think? @johnmlee101 @shubham1206agra
which fools the values order when merging here
Because if Onyx changes, and then this hack would not work.
Do you see any cons for the route based on the name of list value? oldName
and newName
.
We'll have to write more code for Onyx, but other than that?
cc: @cretadn22
I think both solutions would work.
Routes based on index is a bit fragile, don't you think? @johnmlee101 @shubham1206agra
Do you see any cons for the route based on the name of list value?
oldName
andnewName
.
Yeah, there are cons. The first con is to change the route entry in the navigator if someone changes the name. Second con is what if the request fails and the value gets reverted to the old one. It would show not found page.
Plus, why should we rewrite the navigation routes for such a small reason which can be solved easily without any workaround.
That is a fair point π
@johnmlee101 i like @shubham1206agra's proposal. It makes a copy, so even if onyx changes, this solution will still work.
π£ @shubham1206agra π 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 π
Sorry, I missed the assignment notification. I will raise the PR toady.
Payment summary:
@shubham1206agra $250 for PR, paid in Upwork. @rushatgabhane $250 for C+ review, payment pending in NewDot.
@rushatgabhane, do we need a regression test?
yes i think we should add a regression step here because this bug is easy to happen if someone decides to refactor / simplify the logic
The PR that introduced the bug has been identified. Link to the PR: N.A. Original implementation
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
1. Open App
2. Go to workspace settings > Report fields.
3. Click Add field.
4. Click Type and select List.
5. Click List values > Add value.
6. Add the following values - B, C and D.
7. Click on list value C.
8. Click Name field.
9. Change the name to A and save it.
10. Verify that list value A (previously C) will open after renaming.
all set!
$250 approved for @rushatgabhane
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.39-0 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com Issue reported by: Applause Internal Team
Action Performed:
Expected Result:
List value A (previously C) will open after renaming list value C to A.
Actual Result:
List value B opens after renaming list value C to A.
Workaround:
Unknown
Platforms:
Screenshots/Videos
https://github.com/user-attachments/assets/54dd0308-1a32-4127-bc6d-9264d831e3ce
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @rushatgabhane