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.34k stars 2.77k forks source link

Rules - Custom name field is not disabled when Report fields are disabled #49497

Open IuliiaHerets opened 2 hours ago

IuliiaHerets commented 2 hours 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.38-0 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  1. Go to staging.new.expensify.com
  2. Go to Workspace settings > Rules.
  3. Enable "Custom report names".
  4. Go to More features.
  5. Disable Report fields.
  6. Go to Rules.
  7. Click Custom name.
  8. Edit and save it.

Expected Result:

In Step 7, Custom name field should be disabled when Report fields are disabled (similar behavior when Approver field is disabled in category rule when Worflows are enabled).

Actual Result:

In Step 7, Custom name field can be clicked and edited when Report fields are disabled. After editing the custom name, Report fields are enabled.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/38780d0a-2885-4ade-be2c-0f759a5aa1a4

View all open jobs on GitHub

melvin-bot[bot] commented 2 hours ago

Triggered auto assignment to @muttmuure (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 commented 2 hours ago

@muttmuure 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 commented 2 hours ago

Proposal

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

Rules - Custom name field is not disabled when Report fields are disabled

What is the root cause of that problem?

We are not passing customReportNamesUnavailable (!policy?.areReportFieldsEnabled) to disabled prop of MenuItemWithTopDescription here. policy?.areReportFieldsEnabled becomes false when we disable report feilds https://github.com/Expensify/App/blob/98dc643e14378f654e45a7ce96f35be9f407c007/src/pages/workspace/rules/ExpenseReportRulesSection.tsx#L72-L77

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

customReportNamesUnavailable to disabledprop ofMenuItemWithTopDescription`

disabled={customReportNamesUnavailable}

What alternative solutions did you explore? (Optional)

nkdengineer commented 2 hours ago

Proposal

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

In Step 7, Custom name field can be clicked and edited when Report fields are disabled. After editing the custom name, Report fields are enabled.

What is the root cause of that problem?

We update Onyx areReportFieldsEnabled and do not update OnyxshouldShowCustomReportTitleOption when we disable report fields

https://github.com/Expensify/App/blob/25450d96aca5d30b0fef7bdbfc9379fa71e7cd74/src/libs/actions/Policy/Policy.ts#L2903-L2914

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

We should update Onyx key shouldShowCustomReportTitleOption = false when we disable report fields and not show custom name field in Rules page (similar behavior when Track Tax in Distance Rates setting page)

    const policy = getPolicy(policyID);
    const onyxData: OnyxData = {
        optimisticData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
                value: {
                    areReportFieldsEnabled: enabled,
                    shouldShowCustomReportTitleOption: enabled ?? policy?.shouldShowCustomReportTitleOption,
                    pendingFields: {
                        areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                    },
                },
            },
        ],

and need to update successData, failureData as well

What alternative solutions did you explore? (Optional)