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 2024-06-13] [$250] IOU – Previous Expense report title is returned, if save the title as empty #42525

Closed
1 of 6 tasks
lanitochka17 opened this issue May 23, 2024 · 34 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented May 23, 2024

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: 1.4.75-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4569904
Email or phone of affected tester (no customers): applausetester+jp_e_category_1@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Log in
  3. Create new workspace
  4. Create two Submit expenses in WS chat
  5. Navigate to Expense report
  6. Click on title field, delete it and press Save
  7. Observe the title field
  8. Navigate to WS chat via header link
  9. Open Expense report again
  10. Observe the title field

Expected Result:

Unable to save empty Expense report title

Actual Result:

Previous Expense report title is returned, if save the title as empty

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

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

Screenshots/Videos

Add any screenshot/video evidence

Bug6489433_1716470839877.Report_title.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011ce4e42d36033b48
  • Upwork Job ID: 1793667673590427648
  • Last Price Increase: 2024-05-23
  • Automatic offers:
    • cretadn22 | Contributor | 102479025
Issue OwnerCurrent Issue Owner: @bfitzexpensify
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 23, 2024
Copy link

melvin-bot bot commented May 23, 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.

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

@lanitochka17
Copy link
Author

We think that this bug might be related to #vip-vsp

@allgandalf
Copy link
Contributor

Proposal

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

Expense report title doesn't throw error when we save it with empty string

What is the root cause of that problem?

For report fields, we check if the type of reportField is text and set the isRequried prop based on whether the reportField is deletable or not : !reportField.deletable as follows:

{(reportField.type === 'text' || isReportFieldTitle) && (
<EditReportFieldText
fieldName={Str.UCFirst(reportField.name)}
fieldKey={fieldKey}
fieldValue={fieldValue}
isRequired={!reportField.deletable}

Now this is required prop is passed down to the EditReportFieldTextPage component:

if (isRequired && values[fieldKey].trim() === '') {

This will set the error only when isRequried is set to true.

But for all the reportFields, we have deletable set to true.
Screenshot 2024-05-23 at 8 27 36 PM

Hence the assertion for isRequired={!reportField.deletable} is wrong, we should check for the fieldID.

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

We should instead check for the reportField.fieldID prop and only set it to requried if the fieldID is text_title

So the updated code would be:

{(reportField.type === 'text' || isReportFieldTitle) && (
                <EditReportFieldText
                    fieldName={Str.UCFirst(reportField.name)}
                    fieldKey={fieldKey}
                    fieldValue={fieldValue}
                    isRequired={reportField.fieldID === CONST.REPORT_FIELD_TITLE_FIELD_ID}

Note

fieldID are unique for dropdown, date, etc fields for reportFields, The suggested solution will also not cause any regression when we have other field values as well, Also, if we create more text fields for the report, their ID's are different, so this way we make sure that we only make the input as required for the report title and all other reportFields are optional

What alternative solutions did you explore? (Optional)

@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label May 23, 2024
@melvin-bot melvin-bot bot changed the title IOU – Previous Expense report title is returned, if save the title as empty [$250] IOU – Previous Expense report title is returned, if save the title as empty May 23, 2024
Copy link

melvin-bot bot commented May 23, 2024

Job added to Upwork: https://www.upwork.com/jobs/~011ce4e42d36033b48

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

melvin-bot bot commented May 23, 2024

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

@abzokhattab
Copy link
Contributor

abzokhattab commented May 23, 2024

Proposal

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

expense report title allows saving empty empty title

What is the root cause of that problem?

The title field is displayed if reportField.type === 'text' or isReportFieldTitle is true. It is marked as required if reportField.deletableis false, which is incorrect.

According to this comment, the title is editable only if deletable is true, as shown here. Therefore, the title field should be required if it is not disabled. We can use !isReportFieldDisabled(report, reportField, policy) or simply change !reportField.deletable to reportField.deletable.

{(reportField.type === 'text' || isReportFieldTitle) && (
<EditReportFieldText
fieldName={Str.UCFirst(reportField.name)}
fieldKey={fieldKey}
fieldValue={fieldValue}
isRequired={!reportField.deletable}
onSubmit={handleReportFieldChange}
/>

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

  1. change the the required field here to !isReportFieldDisabled(report, reportField, policy) or simply change the !reportField.deletable to reportField.deletable
  2. OR another solution would be to make the field as always required since the EditReportFieldText page is reached only if the field is not disabled. but i would prefer to go with the first solution

Optional: we can make the same change for the date field as well

@cretadn22
Copy link
Contributor

cretadn22 commented May 23, 2024

Proposal

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

The expense report title doesn't generate an error if saved with a blank string.

What is the root cause of that problem?

isRequired={!reportField.deletable}

isRequired={!reportField.deletable}

At these instances, an incorrect condition is employed, resulting in the inadvertent passing of "isRequired: false" to EditReportFieldText

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

isRequired={!reportField.deletable}

isRequired={!reportField.deletable}

In these places, we ought to utilize isReportFieldDeletable that is defined above like this

isRequired={!isReportFieldDeletable}

What alternative solutions did you explore? (Optional)

@eucool
Copy link
Contributor

eucool commented May 23, 2024

Proposal

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

We do not throw error even when we try to save a empty string for Report Title

What is the root cause of that problem?

We decide if we should allow empty string to be stored based on the condition isRequired:

{(reportField.type === 'text' || isReportFieldTitle) && (
<EditReportFieldText
fieldName={Str.UCFirst(reportField.name)}
fieldKey={fieldKey}
fieldValue={fieldValue}
isRequired={!reportField.deletable}
onSubmit={handleReportFieldChange}
/>

But here, the condition for that !reportField.deletable will always return to be false as for all the reportField.fieldID's , the value of deletable will be true. So it doesn't make sense to check on that condition.

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

As every report Field (text, drop-down, date), have their respective fields and the value of deletable is true for all the text fields (be it Report Title or other extra text fields added via OD), I think we can instead have a check isReportFieldTitle:

const isReportFieldTitle = ReportUtils.isReportFieldOfTypeTitle(reportField);

So the updated code would be:

{(reportField.type === 'text' || isReportFieldTitle) && (
                <EditReportFieldText
                    fieldName={Str.UCFirst(reportField.name)}
                    fieldKey={fieldKey}
                    fieldValue={fieldValue}
                    isRequired={isReportFieldTitle} // we updated this value
                    onSubmit={handleReportFieldChange}
                />

This way we do not check the unnecessary reportField.deletable as it will always return to be true. so checking that every time is redundant in this case.

What alternative solutions did you explore? (Optional)

@parasharrajat

This comment was marked as duplicate.

@abzokhattab
Copy link
Contributor

Hi @parasharrajat

I would like to hear your opinion about my proposal. I believe the title field should be required if it is not disabled,
----> meaning when "delectable" is true, not the other way around.

@eucool
Copy link
Contributor

eucool commented May 24, 2024

@parasharrajat , reportField.deletable is true for every reportField which is text, so it really is redundant to even check that:

const isReportFieldDeletable = reportField.deletable && !isReportFieldTitle;

I think my proposal is the most complete one here, as we only rely on isReportFieldTitle value, because we only want to restrict empty string for report title and we want to allow empty title for all other texts added as report fields,

Hence we only want to make the input as required if it is report title!

so can you please rereview the proposal ?

@cretadn22
Copy link
Contributor

@parasharrajat It seems we have a problem, the auto assignment isn't triggered

@parasharrajat
Copy link
Member

reportField.deletable is true for every reportField which is text

@codinggeek2023 It is for now but in future, there might be custom fields here.

It seems we have a problem, the auto assignment isn't triggered

@cretadn22 First the assigned Engineer will review the proposal.

I believe the title field should be required if it is not disabled,
----> meaning when "delectable" is true, not the other way around.

@abzokhattab I didn't understand this. title field is supposed to be always required.

@eucool
Copy link
Contributor

eucool commented May 24, 2024

@codinggeek2023 It is for now but in future, there might be custom fields here.

Indeed that is my point, there are custom text fields even now:
Screenshot 2024-05-24 at 10 14 55 PM

Above test text field is a custom text field which I added on OD, for all the text fields the value of deletable is set to true, also in code, we have different sections for date, dropdown, etc.

So to be very specific to text, deletable will always be true for any kind of text field, be it Expense title or custom text field, so checking deletable is redundant here is what I wanted to emphasise.

Do let me know if you still have any doubts on this @parasharrajat :)

@parasharrajat
Copy link
Member

Ok. Thanks for bringing this up. I still think that checking for deletable is more systematic even though it is true just like we are still passing this value for all text fields even if it is always true.

Also, How is your proposal different from the one above you? I know that it has more details and explanations but the main logic is similar.

I can update the original post to mention that your proposal also works but I can't say that the other one doesn't and let the Engineer decide it.

@eucool
Copy link
Contributor

eucool commented May 24, 2024

I can update the original post to mention that your proposal

yeah that will be alright, also I think you should post the C+ reviewed label again, engineer wasn't assigned here

@cretadn22
Copy link
Contributor

@parasharrajat There are no engineer is assigned

@cretadn22
Copy link
Contributor

cretadn22 commented May 24, 2024

image

As I saw in other issues, @MelvinBot will assign an engineer after this label 🎀 👀 🎀 C+ reviewed. But this issue is exceptional

@parasharrajat
Copy link
Member

Let me fix that.

@parasharrajat
Copy link
Member

@cretadn22 's proposal looks good to me. We can use the existing check that the field is deletable when it is not reportTitleField.

@codinggeek2023 brings up a point that every text field in the app currently is deletable so we don't need to include that check and we can only check for whether the field is reporttitle and set it required.

IMO, Checking for both deletable and reportTitle fields as per @cretadn22's proposal is more systematic. I am not sure if we can remove the deletable part for all text fields.

This is the only difference in @codinggeek2023's proposal rest is the same as @cretadn22's proposal.

Order-wise, @cretadn22's proposal comes before @codinggeek2023's proposal.

Suggestion:

@cretadn22 Please try to be more detailed about the root cause for future proposals. It is important to explain why for each solution.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented May 24, 2024

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

@abzokhattab
Copy link
Contributor

abzokhattab commented May 25, 2024

@abzokhattab I didn't understand this. title field is supposed to be always required.

  • The edit title page will only open if the field is editable. For reference, check the mobile screenshots in this PR to see the current behavior if the field is not editable
  • The field is editable if it is not disabled, as illustrated here and here.
  • If the title field is editable, that means it is not disabled, which means the ReportUtils.isReportFieldDisabled(report, reportField, policy) is true which means happens when the deletable field is true for the title field.
  • Now Regarding the required prop, currently it is enabled if deletable is false, which is incorrect. It should be required if it is editable, meaning isRequired={!ReportUtils.isReportFieldDisabled(report, reportField, policy)} or isRequired={reportField.deletable}.

I believe it would be beneficial to include @allroundexperts in this discussion, as he was the one who implemented this feature.

cc @cristipaval @parasharrajat

Please let me know if you have any further questions.

@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

@cristipaval
Copy link
Contributor

Why Overdue, Melv? 🙄

@melvin-bot melvin-bot bot removed the Overdue label May 27, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels May 29, 2024
@cretadn22
Copy link
Contributor

@parasharrajat The PR is created #42731

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 6, 2024
@melvin-bot melvin-bot bot changed the title [$250] IOU – Previous Expense report title is returned, if save the title as empty [HOLD for payment 2024-06-13] [$250] IOU – Previous Expense report title is returned, if save the title as empty Jun 6, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

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

Copy link

melvin-bot bot commented Jun 6, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.79-11 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-13. 🎊

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

Copy link

melvin-bot bot commented Jun 6, 2024

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:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR:
  • [@parasharrajat] 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:
  • [@parasharrajat] 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:
  • [@parasharrajat] Determine if we should create a regression test for this bug.
  • [@parasharrajat] 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.
  • [@bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 12, 2024
@bfitzexpensify
Copy link
Contributor

Payment summary:

$250 for @parasharrajat for C+ work to be paid via NewDot manual request
$250 for @cretadn22 - paid via Upwork ✅

@parasharrajat, please complete the BZ checklist - thank you!

@parasharrajat
Copy link
Member

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:

Regression Test Steps

  1. Create new workspace
  2. Create two Submit expenses in WS chat
  3. Navigate to Expense report
  4. Click on title field, delete it and press Save
  5. Observe that saving empty Expense report title throws required field error.

Do you agree 👍 or 👎 ?

@bfitzexpensify
Copy link
Contributor

Those steps look great, thank you. Proposed they be added in https://github.com/Expensify/Expensify/issues/404906. We're all done here, thanks everyone.

@parasharrajat
Copy link
Member

Payment requested as per #42525 (comment)

@JmillsExpensify
Copy link

$250 approved for @parasharrajat

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants