Skip to content

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

Description

@izarutskaya

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?

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

Screenshots/Videos

Bug6600629_1726120210498.20240912_134544.mp4

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 12, 2024
  2. melvin-bot commented on Sep 12, 2024

    @melvin-bot

    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.

  3. nyomanjyotisa commented on Sep 12, 2024

    @nyomanjyotisa
    Member

    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

    App/src/libs/ReportUtils.ts

    Lines 2720 to 2722 in 37161bc

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

    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)

  4. daledah commented on Sep 12, 2024

    @daledah
    Contributor

    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

    const sortedPolicyReportFields = useMemo<PolicyReportField[]>((): PolicyReportField[] => {
    const fields = ReportUtils.getAvailableReportFields(report, Object.values(policy?.fieldList ?? {}));
    return fields.filter((field) => field.target === report.type).sort(({orderWeight: firstOrderWeight}, {orderWeight: secondOrderWeight}) => firstOrderWeight - secondOrderWeight);
    }, [policy, report]);

    const mergedFieldIds = Array.from(new Set([...policyReportFields.map(({fieldID}) => fieldID), ...reportFields.map(({fieldID}) => fieldID)]));

    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)

    App/src/libs/actions/Report.ts

    Lines 1992 to 1999 in cfe3d36

    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: {
    fieldList: {
    [fieldKey]: null,
    },
    pendingFields: {
    [fieldKey]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    },

    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)

  5. melvin-bot commented on Sep 17, 2024

    @melvin-bot

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

  6. dylanexpensify commented on Sep 18, 2024

    @dylanexpensify
    Contributor

    reviewing today!

  7. melvin-bot commented on Sep 23, 2024

    @melvin-bot

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

  8. daledah commented on Sep 24, 2024

    @daledah
    Contributor

    @dylanexpensify should we open this issue?

  9. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 25, 2024
  10. melvin-bot commented on Sep 25, 2024

    @melvin-bot
  11. 28 remaining items

  12. changed the title [-][$250] Custom report name - Delete option is present for Title report field but unable to delete it[/-] [+][HOLD for payment 2024-10-14] [$250] Custom report name - Delete option is present for Title report field but unable to delete it[/+] on Oct 7, 2024
  13. melvin-bot commented on Oct 7, 2024

    @melvin-bot

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

  14. melvin-bot commented on Oct 7, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.45-4 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-10-14. 🎊

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

  15. melvin-bot commented on Oct 7, 2024

    @melvin-bot

    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:

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

    @dylanexpensify
    Contributor

    Coming up!

  17. c3024 commented on Oct 15, 2024

    @c3024
    Contributor

    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:

    • [@c3024] The PR that introduced the bug has been identified. Link to the PR: feat: add delete option to deletable report fields #36039
    • [@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
    • [@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.
    • [@c3024] Determine if we should create a regression test for this bug. Yes
    • [@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.
  18. dylanexpensify commented on Oct 16, 2024

    @dylanexpensify
    Contributor

    Payment summary:

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

    Please apply/request!

  19. dylanexpensify commented on Oct 16, 2024

    @dylanexpensify
    Contributor

    @daledah sent offer!

  20. dylanexpensify commented on Oct 17, 2024

    @dylanexpensify
    Contributor

    Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions