Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.54k stars 2.89k forks source link

[HOLD for payment 2024-10-14] [$250] Custom report name - Delete option is present for Title report field but unable to delete it #49077

Closed izarutskaya closed 3 weeks ago

izarutskaya commented 2 months ago

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.33-1 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Rules.
  3. Enable Custom report name.
  4. Click Custom name.
  5. Clear the default value and enter random value.
  6. Save it.
  7. Go to workspace chat.
  8. Submit an expense.
  9. Go to expense report.
  10. Click on the Title report field.
  11. Click 3-dot menu > Delete.
  12. Click Delete.

Expected Result:

The Title report field should disappear after deleting it.

Actual Result:

Title report field remains after deleting it. This issue only happens with Title report field that is enabled by Custom report name.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/38b64d54-7992-4617-878a-1a246f6fe938

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021838887364204259850
  • Upwork Job ID: 1838887364204259850
  • Last Price Increase: 2024-09-25
  • Automatic offers:
    • c3024 | Reviewer | 104208803
Issue OwnerCurrent Issue Owner: @dylanexpensify
melvin-bot[bot] commented 2 months ago

Triggered auto assignment to @dylanexpensify (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.

nyomanjyotisa commented 2 months ago

Edited by proposal-police: This proposal was edited at 2024-09-12 13:33:49 UTC.

Proposal

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

Delete option is present for Title report field but unable to delete it

What is the root cause of that problem?

We should not show Delete option for title field base on this

But the following function not working properly, since we don't use any formula on the Custom name, but instead just a text without formula, the field type will be text. So it not return true in this function https://github.com/Expensify/App/blob/37161bc77fe9b55f4b93d2151d490f698e7adbf3/src/libs/ReportUtils.ts#L2720-L2722

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

Change the function to the following without checking the type

function isReportFieldOfTypeTitle(reportField: OnyxEntry<PolicyReportField>): boolean {
    return reportField?.fieldID === CONST.REPORT_FIELD_TITLE_FIELD_ID;
}

What alternative solutions did you explore? (Optional)

daledah commented 2 months ago

Proposal

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

Title report field remains after deleting it. This issue only happens with Title report field that is enabled by Custom report name.

What is the root cause of that problem?

We're showing the policyReportFields from policy and report

https://github.com/Expensify/App/blob/cfe3d368b1da03c8bed45a8c7edbf4d29bf843db/src/components/ReportActionItem/MoneyReportView.tsx#L70-L73

https://github.com/Expensify/App/blob/cfe3d368b1da03c8bed45a8c7edbf4d29bf843db/src/libs/ReportUtils.ts#L2804

In this case, there's 1 reportField from policy and no one from report

But when users delete field, we don't clear it in policy (just clear fieldList in report)

https://github.com/Expensify/App/blob/cfe3d368b1da03c8bed45a8c7edbf4d29bf843db/src/libs/actions/Report.ts#L1992-L1999

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

the reportField from policy shouldn't be deletable

update isReportFieldDeletable

to

    const isReportFieldFromReport = !!report?.fieldList?.[fieldKey]
    const isReportFieldDeletable = reportField.deletable && !isReportFieldTitle && isReportFieldFromReport

or we can just check isReportFieldDeletable = reportField.deletable && reportField?.fieldID !== CONST.REPORT_FIELD_TITLE_FIELD_ID

If we remove reportField?.type === 'formula' in isReportFieldOfTypeTitle function, it can affected a lot of places

What alternative solutions did you explore? (Optional)

melvin-bot[bot] commented 1 month ago

@dylanexpensify Eep! 4 days overdue now. Issues have feelings too...

dylanexpensify commented 1 month ago

reviewing today!

melvin-bot[bot] commented 1 month ago

@dylanexpensify Eep! 4 days overdue now. Issues have feelings too...

daledah commented 1 month ago

@dylanexpensify should we open this issue?

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

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

ivanmaurovic7 commented 1 month ago

How to login to applausetester+kh010901@applause.expensifail.com? App requires me to input a verification code.

melvin-bot[bot] commented 1 month ago

๐Ÿ“ฃ @ivanmaurovic7! ๐Ÿ“ฃ Hey, it seems we donโ€™t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
ivanmaurovic7 commented 1 month ago

Contributor details Your Expensify account email: ivanmaurovic7@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~01be7ae4f41bd201bf

melvin-bot[bot] commented 1 month ago

โœ… Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] commented 1 month ago

@dylanexpensify @c3024 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

c3024 commented 1 month ago

Asked for some clarification on Slack here.

c3024 commented 1 month ago

If the custom report name is a formula, it is shown as the report name in the header. However, when it is text, it is not shown in the header (because if it were, all reports would have the same title) and is instead displayed as a report field in the report view. This seems like expected behavior to me.

If we remove the formula check in isReportFieldOfTypeTitle, this behavior breaks. It will likely also break the expected behavior because this check is used in many other places. Therefore, I think checking with the field type as REPORT_FIELD_TITLE_FIELD_ID, as suggested in @daledah's proposal, looks good to me.

๐ŸŽ€ ๐Ÿ‘€ ๐ŸŽ€ C+ Reviewed

melvin-bot[bot] commented 1 month ago

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

daledah commented 1 month ago

@mjasikowski What do you think about my proposal? Thanks

mjasikowski commented 1 month ago

@daledah looks good, thank you! We certainly don't want to remove the formula check at this point.

melvin-bot[bot] commented 1 month ago

๐Ÿ“ฃ @c3024 ๐ŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role ๐ŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 1 month ago

๐Ÿ“ฃ @daledah You have been assigned to this job! Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review ๐Ÿง‘โ€๐Ÿ’ป Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs! Keep in mind: Code of Conduct | Contributing ๐Ÿ“–

daledah commented 1 month ago

@c3024 PR is ready.

dylanexpensify commented 1 month ago

pending deploy to prod then regression period

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.45-4 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-10-14. :confetti_ball:

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

melvin-bot[bot] commented 1 month ago

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:

dylanexpensify commented 1 month ago

Coming up!

c3024 commented 3 weeks ago

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:

  • [x] [@c3024] The PR that introduced the bug has been identified. Link to the PR: #36039
  • [x] [@c3024] 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: https://github.com/Expensify/App/pull/36039/files#r1800964733
  • [x] [@c3024] 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: No discussion was started because this could not have been identified earlier.
  • [x] [@c3024] Determine if we should create a regression test for this bug. Yes
  • [x] [@c3024] 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.

Regression Test Proposal

  1. Go to Workspace Rules -> Enable Custom report name.
  2. Clear default custom name value and save a text value in the field
  3. Go to Workspace Chat -> Submit an expense
  4. Go to this expense report just submitted -> Click on the Title Report Field
  5. Verify that either -- there is no three dot menu in the right hand modal (or) -- if there is a three dot menu in the right hand modal, there is no Delete option in it.
dylanexpensify commented 3 weeks ago

Payment summary:

Contributor: @daledah $250 via Upwork Contributor+: @c3024 $250 via Upwork

Please apply/request!

dylanexpensify commented 3 weeks ago

@daledah sent offer!

dylanexpensify commented 3 weeks ago

Done!