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

[HOLD for payment 2025-01-24] [$250] Report fields -System message shows undefined when list value is changed back to initial value #47067

Closed
6 tasks done
IuliiaHerets opened this issue Aug 8, 2024 · 126 comments
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Design External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 8, 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: v9.0.18-1
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 chat.
  3. Submit two expenses.
  4. Go to workspace settings > Report fields (enable in More features).
  5. Add a list type report field, with some list values and an initial value.
  6. Return to the workspace chat.
  7. Go to expense report.
  8. Click on the list report field.
  9. Select a different list value.
  10. Revisit the report.
  11. Click on the list report field.
  12. Click on the already selected value (so that it will change to the initial value).
  13. Revisit the report.

Expected Result:

The system message will not contain "undefined".

Actual Result:

The system message contains "undefined" when the list value is changed back to the initial value.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6565437_1723109214472.20240808_172103.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014a67065c97e4bdba
  • Upwork Job ID: 1822942704704377446
  • Last Price Increase: 2024-08-19
  • Automatic offers:
    • dukenv0307 | Reviewer | 103641179
    • nkdengineer | Contributor | 103641182
    • etCoderDysto | Contributor | 105612296
Issue OwnerCurrent Issue Owner: @dukenv0307
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 8, 2024
Copy link

melvin-bot bot commented Aug 8, 2024

Triggered auto assignment to @bfitzexpensify (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-control

@IuliiaHerets
Copy link
Author

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

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Aug 8, 2024

Edited by proposal-police: This proposal was edited at 2024-08-08 13:17:27 UTC.

Proposal

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

System message shows undefined when list value is changed back to initial value

What is the root cause of that problem?

When selecting the same value (fieldValue === option.text), we assign empty string to fieldKey and pass it to the submit function

onSelectRow={(option) => onSubmit({[fieldKey]: !option?.text || fieldValue === option.text ? '' : option.text})}

Then when value is an empty string we assign null to value prop, update the BE with with a new reportField that has null as a value
const handleReportFieldChange = (form: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORT_FIELDS_EDIT_FORM>) => {
const value = form[fieldKey];
if (isReportFieldTitle) {
ReportActions.updateReportName(report.reportID, value, report.reportName ?? '');
Navigation.goBack();
} else {
ReportActions.updateReportField(report.reportID, {...reportField, value: value === '' ? null : value}, reportField);

Then BE returns a report action object that have null on originalMessage.newValue prop

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

We should remove

|| fieldValue === option.text

from

onSelectRow={(option) => onSubmit({[fieldKey]: !option?.text || fieldValue === option.text ? '' : option.text})}

Or we should change it to

 onSelectRow={(option) => onSubmit({[fieldKey]: option?.text  ??  '' })}

What alternative solutions did you explore? (Optional)

We can dismiss the modal when value is an empty string

if (value) {
ReportActions.updateReportField(report.reportID, {...reportField, value}, reportField);
            }
Navigation.dismissModal(report?.reportID);

@nkdengineer
Copy link
Contributor

nkdengineer commented Aug 8, 2024

Edited by proposal-police: This proposal was edited at 2024-08-08 13:11:00 UTC.

Proposal

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

The system message contains "undefined" when the list value is changed back to the initial value.

What is the root cause of that problem?

If the selected value is the current value of the report field, we pass it as empty string here

onSelectRow={(option) => onSubmit({[fieldKey]: !option?.text || fieldValue === option.text ? '' : option.text})}

Then here we pass the new value of the report field as null

ReportActions.updateReportField(report.reportID, {...reportField, value: value === '' ? null : value}, reportField);

So BE returns the new value in report action as null. Then when merging data to Onyx, the newValue field is deleted since it has null value.

Screenshot 2024-08-08 at 20 02 25

It leads newValue being undefined when we get the message here

return Localize.translateLocal('report.actions.type.changeField', {oldValue, newValue, fieldName});

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

We should add another case when the new value doesn't exist to display a message like remove the ${fieldName} (previously "${oldValue}"). We also need to create a new translation key for this message

if (!newValue) {
    return // translated message;
}

if (!oldValue) {

What alternative solutions did you explore? (Optional)

We can do nothing if the user select the selected value

onSelectRow={(option) => {
    if (fieldValue === option.text || !option?.text) {
        return;
    }
    onSubmit({[fieldKey]: option.text})
}} 

onSelectRow={(option) => onSubmit({[fieldKey]: !option?.text || fieldValue === option.text ? '' : option.text})}
initiallyFocusedOptionKey={selectedOptionKey ?? undefined}

@nkdengineer
Copy link
Contributor

Updated proposal

  • Detail the RCA

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Aug 8, 2024

Updated proposal

  • Added an alternative solution

@melvin-bot melvin-bot bot added the Overdue label Aug 12, 2024
@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label Aug 12, 2024
@melvin-bot melvin-bot bot changed the title Report fields -System message shows undefined when list value is changed back to initial value [$250] Report fields -System message shows undefined when list value is changed back to initial value Aug 12, 2024
Copy link

melvin-bot bot commented Aug 12, 2024

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

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

melvin-bot bot commented Aug 12, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Aug 12, 2024
@dukenv0307

This comment was marked as outdated.

Copy link

melvin-bot bot commented Aug 12, 2024

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

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Aug 12, 2024

@dukenv0307 Can we please ask someone from internal to confirm the expected behaviour? From UX perspective, It doesn't make sense to select the default value when the user is selecting another report field twice. Especially when the user can select the default value if they want.

Report field values are 1, 2, 3. And the default value is 1 in the video. When selecting '2' twice, the value reverts to '1' which is the default value. If the user want to change the value to '1', they can select it form the list.

Screen.Recording.2024-08-12.at.2.12.40.in.the.afternoon.mp4

cc: @grgia @mountiny

@mountiny
Copy link
Contributor

@etCoderDysto can you please write this bug in numbered steps? That will be easier to understand

@etCoderDysto
Copy link
Contributor

@mountiny If we implement The selected solution, the result will be following

Steps

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit two expenses.
  4. Go to workspace settings > Report fields (enable in More features).
  5. Add a list type report field, with some list values and an initial value. (in my video the initial value is '1')
  6. Return to the workspace chat.
  7. Go to expense report.
  8. Click on the list report field.
  9. Select a different list value. (in my video the value is 2)
  10. Click on the list report field.
  11. Click on the already selected value (in my video the value is 2)

Expected Result: The selected report field shouldn't fallback to default report field, and it should be the selected one which is ('2')
Actual result: The selected report field falls back to the initial report field('1') when user selects a report field that is already selected

Attachment:

Screen.Recording.2024-08-12.at.2.12.40.in.the.afternoon.mp4

@mountiny
Copy link
Contributor

@etCoderDysto got it, I agree with that, we should not change to the default.

Can we just close the panel and do nothing when user clicks on the already selected report field?

@nkdengineer
Copy link
Contributor

@mountiny

If we want to do nothing, I believe the proposal from @etCoderDysto doesn't get this expected behavior. This proposal makes the API called then a report action is created with the message displayed like change report field from value1 to value1

I updated my proposal with alternative solution to do that

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Aug 12, 2024

Can we just close the panel and do nothing when user clicks on the already selected report field?

@mountiny When the user selects existing report field, handleReportFieldChange is called with value prop assigned to an empty string. We can check if 'value' is empty string and dismiss the modal when it is. But I have to check if this change won't introduce a regression since handleReportFieldChange is called when editing Date and Text report fields

if (value) {
  ReportActions.updateReportField(report.reportID, {...reportField, value}, reportField);reportField);
            }
Navigation.dismissModal(report?.reportID);

const handleReportFieldChange = (form: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORT_FIELDS_EDIT_FORM>) => {
const value = form[fieldKey];
if (isReportFieldTitle) {
ReportActions.updateReportName(report.reportID, value, report.reportName ?? '');
Navigation.goBack();
} else {
ReportActions.updateReportField(report.reportID, {...reportField, value: value === '' ? null : value}, reportField);

Alternatively, my proposal states that we should call updateReportField, with the existing report field value when user selects existing report field.

@nkdengineer
Copy link
Contributor

@mountiny Additional I think we can do this because for tag or category, we can de-select the select tag/category when we click on the selected option. So I think can do the same for report field.

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Aug 12, 2024

@mountiny

If we want to do nothing, I believe the proposal from @etCoderDysto doesn't get this expected behavior. This proposal makes the API called then a report action is created with the message displayed like change report field from value1 to value1

I updated my proposal with alternative solution to do that

It will make the API call, but there will be no action messages. The action message is only rendered when there is a change in value. And the alternative solution you just proposed won't close the modal, since dismmisModal is called only in handleReportFieldChange

Copy link

melvin-bot bot commented Jan 8, 2025

📣 @etCoderDysto 🎉 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 📖

@etCoderDysto
Copy link
Contributor

@dukenv0307 PR is ready for review

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 17, 2025
@melvin-bot melvin-bot bot changed the title [$250] Report fields -System message shows undefined when list value is changed back to initial value [HOLD for payment 2025-01-24] [$250] Report fields -System message shows undefined when list value is changed back to initial value Jan 17, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 17, 2025
Copy link

melvin-bot bot commented Jan 17, 2025

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

Copy link

melvin-bot bot commented Jan 17, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.86-3 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 2025-01-24. 🎊

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

Copy link

melvin-bot bot commented Jan 17, 2025

@dukenv0307 @bfitzexpensify @dukenv0307 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@garrettmknight garrettmknight moved this from Bugs and Follow Up Issues to Hold for Payment in [#whatsnext] #expense Jan 21, 2025
@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Jan 24, 2025
Copy link

melvin-bot bot commented Jan 27, 2025

@cead22, @grgia, @bfitzexpensify, @dukenv0307, @dubielzyk-expensify, @nkdengineer, @etCoderDysto Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@bfitzexpensify
Copy link
Contributor

@dukenv0307 bump on the BZ checklist

@melvin-bot melvin-bot bot removed the Overdue label Jan 27, 2025
@bfitzexpensify
Copy link
Contributor

Payments complete to @nkdengineer @etCoderDysto

@dukenv0307
Copy link
Contributor

dukenv0307 commented Jan 29, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production
  • 2b. Reported on staging (deploy blocker)
  • 2c. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
Regression Test Proposal Template
  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Test:

Set up before executing test 1, and 2

  1. Go to staging.new.expensify.com
  2. Create a workspace
  3. Go to workspace settings > Report fields (enable in More features).
  4. Add a list type report field, with some list values and an initial value.
  5. Go to the workspace chat
  6. Create an expense

Test 1

  1. Go to the workspace chat
  2. Click on the iou preview
  3. Click on List fields
  4. Click on the already selected value
  5. Verify that there is NO Report_SetFields API call in Dev tools > Networks tab
  6. Navigate to another chat
  7. Navigate back to the expense report details page
  8. Verify that there is no system message for selecting the same report field value

Test 2

  1. Go to the workspace chat
  2. Click on the iou preview
  3. Click on List fields
  4. Select another list field value
  5. Verify that there is Report_SetFields API call in Dev tools > Networks tab
  6. Navigate to another chat
  7. Navigate back to the expense report details page
  8. Verify that there is a system message with a format changed list fields from A to B or changed list fields to C

Do we agree 👍 or 👎

@dukenv0307
Copy link
Contributor

@bfitzexpensify I completed the BZ. Thank for bumping me

@bfitzexpensify
Copy link
Contributor

Thanks. Proposed the regression test steps, and finalised payment.

@github-project-automation github-project-automation bot moved this from Hold for Payment to Done in [#whatsnext] #expense Jan 29, 2025
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 Design External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests