Open IuliiaHerets opened 2 hours ago
Triggered auto assignment to @johncschuster (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.
@johncschuster 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
Report fields - Same list values can be saved without error
We are passing list values from draft (formDraft?.[INPUT_IDS.LIST_VALUES]
) to validateReportFieldListValueName
. And formDraft?.[INPUT_IDS.LIST_VALUES]
is undefined when editing saved report list and empty array will be passed to validateReportFieldListValueName
as list of values. And no error will be thrown since the newly added value is not in the empty list
https://github.com/Expensify/App/blob/4c9a3fbac779689ec6abade55df8234b1b859e51/src/pages/workspace/reportFields/ReportFieldsAddListValuePage.tsx#L42
We should pass existing field values when there is no draft lists (formDraft?.[INPUT_IDS.LIST_VALUES]
)
const reportFieldKey = ReportUtils.getReportFieldKey(reportFieldID);
const fieldValues = policy?.fieldList?.reportFieldKey?.values;
validateReportFieldListValueName
when there is no draft field values
WorkspaceReportFieldUtils.validateReportFieldListValueName(
values[INPUT_IDS.VALUE_NAME].trim(),
'',
formDraft?.[INPUT_IDS.LIST_VALUES] ?? fieldValues ?? [],
Note: Optionally if reportFieldID is undefined we can pass formDraft?.[INPUT_IDS.LIST_VALUES]
to validateReportFieldListValueName
and pass existing report fields (fieldValues
) when it not undefined.
Edited by proposal-police: This proposal was edited at 2024-09-20 11:57:13 UTC.
Report fields - Same list values can be saved without error
When editing a report field, we are passing the form draft data as the value list. This is incorrect. The form draft data should only be used when creating a new field, not when editing, as the draft data is empty during field editing. https://github.com/Expensify/App/blob/4c9a3fbac779689ec6abade55df8234b1b859e51/src/pages/workspace/reportFields/ReportFieldsAddListValuePage.tsx#L42
If the report field ID exists, it means the field is not a draft, so we can use the policy field. Otherwise, we should use the draft value:
const reportFieldKey = ReportUtils.getReportFieldKey(reportFieldID);
const reportFieldValues = reportFieldID
? Object.values(policy?.fieldList?.[reportFieldKey]?.values ?? {})
: formDraft?.[INPUT_IDS.LIST_VALUES] ?? [];
Then update the following line:
WorkspaceReportFieldUtils.validateReportFieldListValueName(
values[INPUT_IDS.VALUE_NAME].trim(), '', reportFieldValues, INPUT_IDS.VALUE_NAME
);
Note that we have to wrap the values returned from the field with Object.values()
to get the values array and use it in the validateReportFieldListValueName
, otherwise it will not work.
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.38-1 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+sdsddh2@applause.expensifail.com Issue reported by: Applause Internal Team
Action Performed:
Expected Result:
App will show error when adding same list value in Step 9.
Actual Result:
App does not show error when adding same list value in Step 9. User can add the same list values many times without issue. When selecting one of the same list values via checklist, all the same values are selected and the dropdown button shows "1 selected".
Workaround:
Unknown
Platforms:
Screenshots/Videos
https://github.com/user-attachments/assets/08ffa841-0178-40eb-9aa7-e44f9195298d
View all open jobs on GitHub