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.56k stars 2.9k forks source link

[HOLD for payment 2024-10-29] [$250] QBD - Category title link shows "undefined settings" when there is error with QBO connection #49394

Closed IuliiaHerets closed 1 week ago

IuliiaHerets 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.37-0 Reproducible in staging?: Y Reproducible in production?: Y Issue was found when executing this PR: https://github.com/Expensify/App/pull/48759 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.
  3. Go to Categories.

Expected Result:

The link in the header will not show "undefined settings".

Actual Result:

The link in the header shows "undefined settings". The same issue goes for Tags and Report fields.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/f0b8352f-c955-4c2b-bb39-91f45758265b

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021837252793117015940
  • Upwork Job ID: 1837252793117015940
  • Last Price Increase: 2024-09-20
  • Automatic offers:
    • brunovjk | Contributor | 104158165
Issue OwnerCurrent Issue Owner: @alexpensify
melvin-bot[bot] commented 2 months ago

Triggered auto assignment to @alexpensify (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 months ago

We think that this bug might be related to #wave-control

IuliiaHerets commented 2 months ago

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

abzokhattab commented 2 months ago

Edited by proposal-police: This proposal was edited at 2024-09-18 16:04:34 UTC.

Proposal

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

The category title link displays "undefined settings."

What is the root cause of that problem?

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

OR

Instead of displaying undefined for unsupported connections, we can still retrieve the connection name regardless of whether it is supported, as Tom mentioned here . To achieve this, we have two options:

  1. We can update the getCurrentConnectionName function so that it only checks CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY, which contains both supported and unsupported connection names, and remove CONST.POLICY.CONNECTIONS.NAME:
function getCurrentConnectionName(policy?: Policy): string | undefined {
    if (!policy?.connections) {
        return undefined;
    }

    const connectionNames = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY;

    for (const key of Object.keys(connectionNames)) {
        if (policy.connections[key]) {
            return connectionNames[key];
        }
    }

    return undefined;
}
  1. Or, we can create a new function that uses the same logic as above but with a different function name. This would help avoid potential issues elsewhere in the code. In this case, we need to update the function calls here , here , and here, here to use this new function. but i recommend to update the current function to keep everything consistent
  2. finally in the accounting page we need to show a message in case any of the current connections are unsupported so that the user can check it, to do that we need to add the following component here
         {hasUnsupportedNDIntegration && !hasSyncError && (
                                <FormHelpMessage
                                    isError
                                    shouldShowRedDotIndicator
                                >
                                    <Text style={[{color: theme.textError}]}>
                                        {translate('workspace.accounting.unSupportedIntegration')}
                                        <TextLink
                                            onPress={() => {
                                                Link.openOldDotLink(CONST.OLDDOT_URLS.POLICY_CONNECTIONS_URL(policyID));
                                            }}
                                        >
                                            {translate('workspace.accounting.manageYourSettings')}
                                        </TextLink>
                                    </Text>
                                </FormHelpMessage>
                            )}

    note: we might not need to warp it with FormHelpMessage as the user didn't make anything wrong ( the connection is not supported form our side), so it shouldn't be shown as error, we can just show the TextLink for without wrapping it.

mkzie2 commented 2 months ago

Edited by proposal-police: This proposal was edited at 2024-09-24 09:51:46 UTC.

Proposal

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

What is the root cause of that problem?

1. Display The categories below are imported from QuickBooks Desktop (or the name of the connected integration, even if it's not yet supported) to make the messaging consistent.

https://github.com/Expensify/App/blob/740484c622ae1f56393c372741106b1af1d197dc/src/libs/PolicyUtils.ts#L952

function getCurrentConnectionName(policy: Policy | undefined, includeUnsupportedConnection = false): string | undefined {
    const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME);
    if (includeUnsupportedConnection) {
        accountingIntegrations.push(...Object.values(CONST.POLICY.UNSUPPORTED_CONNECTIONS.NAME));
    }
    const connectionKey = accountingIntegrations.find((integration) => !!policy?.connections?.[integration]);
    return connectionKey ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionKey] : undefined;
}

By introducing a includeUnsupportedConnection param, we can make sure our change in this PR does not break other logics.

    const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy, true);
    const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
    const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
    const hasSyncError = PolicyUtils.hasSyncError(policy, isSyncInProgress);

The text "The categories below are imported from your Quickbooks Desktop settings" should not be displayed if the connection encountered an error. We will use hasSyncError to decide whether we should display that text or not.

https://github.com/Expensify/App/blob/ace39e86b7f6a5015f1cc5722f8b739ff99ebab9/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx#L283

            {!hasSyncError && isConnectedToAccounting ? (

image If the connection is not supported and successful.

image if the connection is not supported and there is an error.

2. On the policy's accounting page, show the Go to Expensify Classic to manage your settings. text.

To do it, add another logic to handle that case to: https://github.com/Expensify/App/blob/1c39bd2bd896a573373b7ab357edc42e6ea48246/src/pages/workspace/accounting/PolicyAccountingPage.tsx#L495

                          {hasUnsupportedNDIntegration && !hasSyncError && (
                                <FormHelpMessage shouldShowRedDotIndicator={false}>
                                    <Text>
                                        <TextLink
                                            onPress={() => {
                                                // Go to Expensify Classic.
                                                Link.openOldDotLink(CONST.OLDDOT_URLS.POLICY_CONNECTIONS_URL(policyID));
                                            }}
                                        >
                                            {"Go to Expensify Classic to manage your settings"}
                                        </TextLink>
                                    </Text>
                                </FormHelpMessage>
                            )}
  1. Remove hasSyncError conditions in: https://github.com/Expensify/App/blob/1c39bd2bd896a573373b7ab357edc42e6ea48246/src/pages/workspace/accounting/PolicyAccountingPage.tsx#L462

  2. Remove !(hasUnsupportedNDIntegration && hasSyncError) in: https://github.com/Expensify/App/blob/1c39bd2bd896a573373b7ab357edc42e6ea48246/src/pages/workspace/accounting/PolicyAccountingPage.tsx#L380

  3. Update hasUnsupportedNDIntegration variable to:

    const hasUnsupportedNDIntegration = !isEmptyObject(policy?.connections) && PolicyUtils.hasUnsupportedIntegration(policy, accountingIntegrations);

image in case "the connection is not supported and successful".

What alternative solutions did you explore? (Optional)

Details - We should change logic: https://github.com/Expensify/App/blob/ace39e86b7f6a5015f1cc5722f8b739ff99ebab9/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx#L283 ``` {!hasSyncError && hasUnsupportedIntegration ? ( {`The categories below have been imported from the connection configured in `} { // Go to Expensify Classic. Link.openOldDotLink(CONST.OLDDOT_URLS.POLICY_CONNECTIONS_URL(policyId)); }} > {`Expensify Classic`} . ) : !hasSyncError && isConnectedToAccounting ? ( ``` in there ```hasUnsupportedIntegration``` is ``` const hasUnsupportedIntegration = isConnectedToAccounting && PolicyUtils.hasUnsupportedIntegration(policy, Object.values(CONST.POLICY.CONNECTIONS.NAME)); ``` and ```hasSyncError``` is ``` const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`); const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy); const hasSyncError = PolicyUtils.hasSyncError(policy, isSyncInProgress); ``` - It will display something like: ![image](https://github.com/user-attachments/assets/43d0d840-d206-4942-b930-3f5b32726028) if there is a successful connection which is not supported in ND and when user clicks on "Expensify Classic", it will open OD app like we did in: https://github.com/Expensify/App/blob/f7a4aa13979ae71631df79a6ac181c2e9b08f17f/src/pages/workspace/accounting/PolicyAccountingPage.tsx#L491 - We should apply the same fix in tag, reportField, taxes page.
melvin-bot[bot] commented 2 months ago

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

melvin-bot[bot] commented 2 months ago

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

alexpensify commented 2 months ago

@brunovjk when you get a chance, can you please review the proposals? Thanks!

brunovjk commented 2 months ago

@brunovjk when you get a chance, can you please review the proposals? Thanks!

Sure!

shubham1206agra commented 2 months ago

I don't think QBD is implemented at all. cc @lakchote @dylanexpensify

brunovjk commented 2 months ago

Appreciate the insights @shubham1206agra! I will hold off on the proposal review until the last comment has been addressed :D

abzokhattab commented 1 month ago

While adding QuickBooks Desktop (QBD) would resolve the issue for that connection, this "undefined settings" error may still occur with other unsupported connections. To ensure broader coverage and prevent similar issues, I recommend considering the alternative solution proposed, which addresses undefined connections more comprehensively.

alexpensify commented 1 month ago

I'm confused, this GH is about QBO, not QBD. Why did we pivot to talk about QBD?

lakchote commented 1 month ago

I don't understand why we're talking about QBD either here. We're talking about QBO. QBD is not yet implemented in NewDot.

mkzie2 commented 1 month ago

@lakchote The QBD is not yet implemented in NewDot. But there are a few cases where the QBD term is still displayed in ND, such as our current issue and that issue.

brunovjk commented 1 month ago

It seems the confusion stems from the fact that this issue was initially labeled as QBO, but the actual functionality being tested in the video and steps involves QBD (QuickBooks Desktop), not QBO (QuickBooks Online).

Here's a summary:

POC https://github.com/user-attachments/assets/f36728c8-7009-4378-93ed-f1fc9de6ff6b

I reviewed both proposals (using the alternative solution from the first one), and they are quite similar. While the first proposal from @abzokhattab suggests "avoiding the display of the 'categories below are imported from...' message if the connection name is undefined," I believe the second one from @mkzie2 —which involves adding a message informing the user that certain features like QBD categories and tags are not yet supported—is more appropriate, provided that this issue is confirmed.

@alexpensify @lakchote @shubham1206agra @IuliiaHerets Does this make sense or am I missing something? Thank you :D

abzokhattab commented 1 month ago

I have a question: if the connection setup fails, will the categories still be imported from the failed connection?

If not, I think it makes sense not to display that label here .

Instead, we could add another label warning the user to check the connection page for a potential failed connection, rather than informing them that the categories were imported

lakchote commented 1 month ago

It does make sense @brunovjk, thanks!

The issue's title is misleading, it's indeed about QBD and not QBO cc @IuliiaHerets

QBD in NewDot will soon be supported, and is already supported in OldDot.

Regarding what to do between these 2 choices:

  1. avoiding the display of the categories below are imported from... message if the connection name is undefined
  2. adding a message informing the user that certain features like QBD categories and tags are not yet supported

I'd go with helping the user by informing him on the current status of the integration. If it failed to connect, use a specific message. If it's not supported yet, do the same.

I'm going to tag @JmillsExpensify @trjExpensify what would you go with?

trjExpensify commented 1 month ago

QBD in NewDot will soon be supported, and is already supported in OldDot.

How far away are we from building QBD workspace settings out in NewDot? I'm a bit mindful of investing in throwaway work with QBD coming soon. That said, we could hit the "undefined" message with Certina (FinancialForce) as well I guess which is a little further out - but not a million miles away.

Can't we know from the policy object which accounting solution is connected to the workspace already, and show it's name instead of undefined on the categories and tags page here like normal?

image

Then on the accounting page replace this message with a generic _"Go to Expensify Classic to manage your settings." which we'll remove in turn for QBD and Certina as those are built:

image
lakchote commented 1 month ago

How far away are we from building QBD workspace settings out in NewDot? I'm a bit mindful of investing in throwaway work with QBD coming soon. That said, we could hit the "undefined" message with Certina (FinancialForce) as well I guess which is a little further out - but not a million miles away.

That's a fair concern. QBD should start to be implemented by the end of the month/early October. We could do this in advance yes, as it can impact other integrations down the line if they're not supported.

Can't we know from the policy object which accounting solution is connected to the workspace already, and show it's name instead of undefined on the categories and tags page here like normal? Yes, we can.

What you suggest make sense:

  1. Display The categories below are imported from QuickBooks Desktop (or the name of the connected integration, even if it's not yet supported) to make the messaging consistent.
  2. On the policy's accounting page, show the Go to Expensify Classic to manage your settings. text.
abzokhattab commented 1 month ago

Proposal Updated

Updated my alternative solution to show the correct connection name regardless of whether the connection is supported or not

mkzie2 commented 1 month ago

Proposal updated

I updated the main solution

brunovjk commented 1 month ago

I will review it later today.

brunovjk commented 1 month ago

I liked the update from @abzokhattab's proposal for its simplicity, I tested it and it solves our main issue. Screenshot 2024-09-25 at 18 27 26

I did a quick test on the app with those changes and didn't came across any issue, @abzokhattab you commented "Or, we can create a new function that uses the same logic as above but with a different function name. This would help avoid potential issues elsewhere in the code.", did you find anything in your tests? Also @abzokhattab your proposal is incomplete, it needs to be taken into consideration with the second comment from trjExpensify here: "Then on the accounting page replace this message with a generic "Go to Expensify Classic to manage your settings." which we'll remove in turn for QBD and Certina as those are built:"

@mkzie2 's proposal also seems ok, more robust, but I'm afraid it's bit over-engineered. @mkzie2 Correct me if I'm wrong, but I didn't see that we should "The text "The categories below are imported from your Quickbooks Desktop settings" should not be displayed if the connection encountered an error" as mentioned in your proposal.

abzokhattab commented 1 month ago

did you find anything in your tests?

I have checked that deeply now and i think we can safely modify the existing method instead of creating another one or modifying the existing one by adding a new arg

needs to be taken into consideration with the second comment from

Updated the proposal to handle this point

mkzie2 commented 1 month ago

I didn't see that we should "The text "The categories below are imported from your Quickbooks Desktop settings" should not be displayed if the connection encountered an error" as mentioned in your proposal.

image

I'm afraid it's bit over-engineered

Display The categories below are imported from QuickBooks Desktop (or the name of the connected integration, even if it's not yet supported) to make the messaging consistent. On the policy's accounting page, show the Go to Expensify Classic to manage your settings. text.

brunovjk commented 1 month ago

Thank you both for the updates and hard work. I appreciate the thoughtful approaches and carefully reviewed both proposals.

@abzokhattab: Although I like to look for the simplest solution, your proposal feels incomplete: It’s unclear how it handles scenarios like successful vs. failed connections.

@mkzie2: Apologies for my earlier wording—I wasn’t suggesting your solution was over-engineered, I was concern about not to do it. After a closer look, I see it’s robust, handling both current and future integrations well. I also liked the use of hasSyncError for clearer user messaging.

I think we can move forward with @mkzie2's proposal, but I’d love that @justinpersaud take a look at the proposal and share their thoughts before moving on. Thank you.

🎀👀🎀 C+ reviewed

melvin-bot[bot] commented 1 month ago

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

justinpersaud commented 1 month ago

Sounds good to me!

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

📣 @mkzie2 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 📖

justinpersaud commented 1 month ago

Woops I double clicked on the assignee button and hit the clear asignees button, so upwork job should actually be for @mkzie2

melvin-bot[bot] commented 1 month ago

@justinpersaud, @alexpensify, @brunovjk, @mkzie2 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

brunovjk commented 1 month ago

Not overdue, PR being raised. @mkzie2 do you have an estimated deadline? Thanks.

alexpensify commented 1 month ago

Update: PR is in review

alexpensify commented 1 month ago

Weekly Update: PR is still in review

alexpensify commented 1 month ago

Heads up, I will be offline until Tuesday, October 22, 2024, and will not actively watch over this GitHub during that period.

If this GitHub requires an urgent update, please ask for help in the #expensify-open-source Slack Room. If the inquiry can wait, I'll review it when I return online.

flaviadefaria commented 1 month ago

This shouldn't be part of the #migration project as it isn't related to one of the upcoming cohorts. #retain is probably a better place for this issue.

trjExpensify commented 1 month ago

I agree it shouldn't be in #migrate, but it should be in #expense where QBD is being actively built. We're just waiting out the regression period here. Hit staging on Friday.

melvin-bot[bot] commented 4 weeks ago

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

melvin-bot[bot] commented 4 weeks ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.51-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-29. :confetti_ball:

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

melvin-bot[bot] commented 4 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:

mkzie2 commented 4 weeks ago

@brunovjk Please note that as of today we already support QBD integration, only this test case is valid:

  1. In OD, try to connect to Quickbooks Desktop but do not complete the set up to trigger error
  2. In ND, open workspace settings > Categories
  3. Verify Get a better overview of where money is being spent... message shows under Categories title
brunovjk commented 3 weeks ago

BugZero Checklist:

Regression Test Proposal

  1. Setup on OldDot (OD):

    • Go to Settings -> Workspaces in OD.
    • Select a Workspace.
    • Navigate to Connections -> QuickBooks Desktop -> Click Connect to QuickBooks Desktop.
    • When prompted with next steps, close the modal without completing the setup.
    • Refresh the page and confirm the error message: "The connection could not be completed".
  2. Verification on NewDot (ND) with Connection Error:

    • Tap on the profile photo in the navbar, and navigate to Workspaces.
    • Select the same workspace as above.
    • Under Accounting, confirm that an error message appears: "There's an error with the connection...".
    • Still on Workspace settings, verify each of these tabs: Categories, Report Fields, Taxes and Tags displays their default message (Example Categories: "Get a better overview of where money is being spent...").
  3. Reconnect and Verify Successful Integration:

    • Return to OD and fully complete the connection setup with QuickBooks Desktop.

    • In ND, go to Workspace settings

    • Confirm that each tab now shows the message: "The [Categories/Report Fields/Taxes/Tags] below are imported from QuickBooks Desktop settings."

    • Click QuickBooks Desktop settings on any tab, and verify that the message "Go to Expensify Classic to manage your settings." appears without any integration menu (Import, Export, Advanced...) or error message.

    • Do we agree 👍 or 👎

alexpensify commented 3 weeks ago

Payouts due: 2024-10-29

Upwork jobs are above.

alexpensify commented 2 weeks ago

All set, the payments are complete here. @justinpersaud do you agree with this regression test? If yes, I can create the GH. Thanks!

justinpersaud commented 2 weeks ago

yep, sounds good to me

alexpensify commented 2 weeks ago

Ok, I'll work on the test process.

alexpensify commented 2 weeks ago

Other GHs have been a priority; I need to circle back here and create the regression test GH.