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

Fix GBR and error briefly show after connecting to QBO, Xero. #47483

Merged
merged 25 commits into from
Sep 2, 2024

Conversation

hungvu193
Copy link
Contributor

@hungvu193 hungvu193 commented Aug 15, 2024

Details

While connecting to QBO or Xero, we will see an error message briefly at the end of the process, this PR will fix it.

Fixed Issues

$ #44148

#47855
PROPOSAL: N/A

Tests

  1. Create a new workspace and enable Accounting feature.
  2. Go to Accounting, click the Connect button right next to QBO (or Xero).
  3. Verify there's no error shown briefly.
  4. From QBO (or Xero dashboard), try to disconnect the Expensify App.
  5. Go back to the app, and try to sync a few times, until you see Enter credentials options, click on that.
  6. Enter correct credentials and go back to the Expensify app.
  7. Verify that RBR shouldn't appear while syncing.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as Tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2024-08-20.at.09.36.21.mov
Android: mWeb Chrome
Screen.Recording.2024-08-20.at.09.27.42.mov
iOS: Native
Screen.Recording.2024-08-20.at.09.32.33.mov
iOS: mWeb Safari
Screen.Recording.2024-08-20.at.09.18.00.mov
MacOS: Chrome / Safari
Screen.Recording.2024-08-19.at.22.14.31.mov
MacOS: Desktop
Screen.Recording.2024-08-19.at.22.32.17.mov

@hungvu193
Copy link
Contributor Author

Hold for #44148 (comment)

@hungvu193 hungvu193 marked this pull request as ready for review August 19, 2024 16:18
@hungvu193 hungvu193 requested a review from a team as a code owner August 19, 2024 16:18
@melvin-bot melvin-bot bot requested review from getusha and removed request for a team August 19, 2024 16:18
Copy link

melvin-bot bot commented Aug 19, 2024

@getusha Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@hungvu193
Copy link
Contributor Author

hungvu193 commented Aug 19, 2024

This should be ready for your review @war-in and @arosiclair . I'll complete the rest of the screenshots/videos tomorrow morning.

Copy link
Contributor

@arosiclair arosiclair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far

@hungvu193
Copy link
Contributor Author

Completed the screenshots/videos.

@getusha
Copy link
Contributor

getusha commented Aug 20, 2024

@hungvu193 @arosiclair should i review this or it's handled as part of a project with someone else?

Copy link
Contributor

@war-in war-in left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only one question

@hungvu193
Copy link
Contributor Author

@hungvu193 @arosiclair should i review this or it's handled as part of a project with someone else?

Please hold your review. I think this PR is a follow-up of our current issue that we're working on 😄

@arosiclair
Copy link
Contributor

@hungvu193 @arosiclair should i review this or it's handled as part of a project with someone else?

Please hold your review. I think this PR is a follow-up of our current issue that we're working on 😄

Nope this shouldn't be held on anything. We need to fix #44148. Please fix the new conflicts and then review @hungvu193 @getusha.

@getusha
Copy link
Contributor

getusha commented Aug 25, 2024

We don't want to display error message even if there's errorMessage unless connection?.lastSync?.isSuccessful is false, that's why 😄

I am not suggesting that. the condition is returning early if you look closely.

@hungvu193
Copy link
Contributor Author

I am not suggesting that. the condition is returning early if you look closely.

I mean, checking !connection?.lastSync?.errorMessage is not necessary, the only case we want to display errorMessage is when connection?.lastSync?.isSuccessful is false.

Nevermind, can you please use staging env to test Xero connection again? I've just checked and it seems working fine.

@getusha
Copy link
Contributor

getusha commented Aug 25, 2024

Nevermind, can you please use staging env to test Xero connection again? I've just checked and it seems working fine.

Of course it will appear to work since we are not showing an error when the last sync isn't a success based on your recent change.

https://github.com/Expensify/App/pull/47483/files#diff-1b4d0097f39f938389f788ddb79e471094a86831de5e33967693d9a3705b9ebeR387

if (isSyncInProgress || isEmptyObject(connection?.lastSync) || connection?.lastSync?.isSuccessful === false) {

I mean, checking !connection?.lastSync?.errorMessage is not necessary, the only case we want to display errorMessage is when connection?.lastSync?.isSuccessful is false.

Why do we want to show an empty error message?

@hungvu193
Copy link
Contributor Author

Why do we want to show an empty error message?

If connection?.lastSync?.isSuccessful isn't false, there won't be errorMessage, if connection?.lastSync?.errorMessage still have truly value, that will be BE issue, we also checked falsely value for errorMessage here so it won't be a problem:

const synchronizationError = connectedIntegration && getSynchronizationErrorMessage(policy, connectedIntegration, isSyncInProgress);
// Enter credentials item shouldn't be shown for SageIntacct and NetSuite integrations
const shouldShowEnterCredentials =
connectedIntegration &&
!!synchronizationError &&

Of course it will appear to work since we are not showing an error when the last sync isn't a success based on your recent change.

Damn, that's bad merge, I'll update it shortly

@hungvu193
Copy link
Contributor Author

As I checked the logs, connection?.lastSync?.isSuccessful return false, then return true that's why we saw the error briefly.
Any thoughts? @arosiclair

Screenshot 2024-08-25 at 18 50 18

@arosiclair
Copy link
Contributor

As I checked the logs, connection?.lastSync?.isSuccessful return false, then return true that's why we saw the error briefly. Any thoughts? @arosiclair

What steps did you take to reproduce and with what integration?

@hungvu193
Copy link
Contributor Author

hungvu193 commented Aug 26, 2024

As I checked the logs, connection?.lastSync?.isSuccessful return false, then return true that's why we saw the error briefly. Any thoughts? @arosiclair

What steps did you take to reproduce and with what integration?

Here is the steps:
Precondition: use Staging env

  1. Disconnect Xero if you're connected
  2. Connect with Xero
  3. Log the value of connection inside "getSynchronizationErrorMessage" function.

@hungvu193
Copy link
Contributor Author

I can also reproduce this on Staging.
There're 2 Pusher events were pushed almost at the same time, one event sent isSuccessful: false, the other one sent isSuccessful: true.

[info] [Report] Handled multipleEvents event sent by Pusher - {"updates":[{"data":[{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"enableNewCategories":true}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"export":{"billDate":"LAST_EXPENSE","billStatus":{"purchase":"AWT_PAYMENT","sales":"AWT_PAYMENT"},"billable":"SALES_INVOICE","exporter":"visaocuoitroi193+10@gmail.com","nonReimbursable":"BANK_TRANSACTION","nonReimbursableAccount":"","reimbursable":"BILL"}}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"importCustomers":true}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"importTaxRates":false}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"importTrackingCategories":true}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"isConfigured":false}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"mappings":{"customer":"DEFAULT"}}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"sync":{"hasChosenAutoSyncOption":true,"hasChosenSyncReimbursedReportsOption":true,"invoiceCollectionsAccountID":"","reimbursementAccountID":"","syncReimbursedReports":true}}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"data":{"bankAccounts":[],"revenueAccounts":[],"trackingCategories":[]}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"lastSync":{"errorDate":"","errorMessage":"","isAuthenticationError":false,"isConnected":false,"isSuccessful":false,"source":"","successfulDate":""}}}}}],"eventType":"onyxApiUpdate"}],"lastUpdateID":1408169430,"previousUpdateID":1408168356} 
Log.ts:75 [info] [Report] Handled multipleEvents event sent by Pusher - {"updates":[{"data":[{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"credentials":{"access_token":"OmVpg4a8+OCf9P7I4AoGEQjJuPpM7WqJsxmSjFPUuXAd8nNZT9+rsoVIaUunZVCQODVl7qwM4Lx4iWyF55eY+w/ZUbliljsniSnzeLggWTR/p2h6s6jnw5hxJ1Z+Ngw7U5cdQDim3pQ3/DmJMlG27G8GuQqbALMh6z0A5bjETbtihjB7RbBJl9mCD+wfF+qiA5JC85KAhLhN9k4MsngV8wxG/qoPYUMm2Cv3HZ30PG9Foq+0IaR+/qBc7qEbcatGPJ8tFk/FN90SxjWsAp2r0yq8nzOsJPsZcR8a4Ol/JEECUy8x6AREJAwo8eI/kCdOQX94P5p2UMHK+s/2YE5D+DZzGFh+yI63qXaZv1FkCYRWSoXMLsJExt5jlkO78gnuTh8YSTGSViGlcRgMctxCDtHqLr4WwtBdjtueOIVzlg7c+rUnPzmDGoKnvVbuOlVwDmQJSMLf1e03jb9CtW0+wp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/uj/EbSlRmn5XqQFm/2hUVHhOVrRc5Oj0P6QNU0j3pLeehiax0WnUw4z3pXsrdxxGODt31BA8s/rFKeJ+GCXAVPc1wUnVagFS4Iw1eVkGjCXeXUB1sjcJc8fujH0Damy19zjEJLoKFdoM0bYuyn+w5P42DgTfELabJI0/xA3Wv48NT+WsnlGSMvuaTDt6OH2mvHrnb655wA4wKUSRfgGgBjqp4fHhdlq2j2n875zD3AK0v0p6ff2P1A5wMKoLhzFhh1vAiDJNDP+Ogc=;g4JK0vsb1lWz7ThCG1BkFw==;UvDb7btqYTj6s/YOnYff6r7V9RRm+crJgDhevs7b6dMdfswIk4w9MfF0k2smEzptuL+3vGR76o4IYEhRudK3cA=="}}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"config":{"credentials":{"refresh_token":"JKCpcHCKzMY7vOII8mlnSalFw3asTiHWgLZ4Ch07N7gb8/ogBsFknUQO4QKUw+iP;oOIqK5eJp9mrYz/FF7C5vQ==;gl2RaPsH1mkjQ4+0hWe79aSnMrrV607Cl8oU7W5weS+vCzneDUpWrVzD8shomggIvpSp0v/A6eppKCn3dJPSSA=="}}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"data":{"countryCode":"VN"}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"data":{"organisationID":"d98ac19e-d0a4-47ff-b798-e902b46605e5"}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"data":{"revenueAccounts":[{"id":"9ae129c6-f457-4a01-8f6b-1fc1198ebb87","name":"Owner A Drawings"},{"id":"77c628a0-1b47-4c96-ac04-2d810412b0c8","name":"Owner A Funds Introduced"},{"id":"05c8356b-5637-4cdd-b821-de0daab2140f","name":"Owner A Share Capital"}]}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"data":{"tenants":[{"id":"d98ac19e-d0a4-47ff-b798-e902b46605e5","name":"TESST TENANT","value":"!PwkV1"}]}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"lastSync":{"isConnected":true}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"lastSync":{"isSuccessful":true}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"lastSync":{"source":"NEWEXPENSIFY"}}}}},{"key":"policy_57692AA062EC69B3","onyxMethod":"merge","value":{"connections":{"xero":{"lastSync":{"successfulDate":"2024-08-26T14:42:51+0000"}}}}}],"eventType":"onyxApiUpdate"}],"lastUpdateID":1408170694,"previousUpdateID":1408169817} 

@arosiclair
Copy link
Contributor

Thanks I'm looking into it now. I think I can reproduce as well.

src/libs/actions/connections/index.ts Outdated Show resolved Hide resolved
hungvu193 and others added 2 commits August 29, 2024 00:06
Add suggestions

Co-authored-by: Andrew Rosiclair <arosiclair@gmail.com>
@hungvu193
Copy link
Contributor Author

It's working fine after latest changes, @getusha would you mind to retest it? ty 😄

@hungvu193
Copy link
Contributor Author

little bump @getusha, it's close to merge

@trjExpensify
Copy link
Contributor

@hungvu193 conflicts to fix here. Thanks!

@hungvu193
Copy link
Contributor Author

@hungvu193 conflicts to fix here. Thanks!

Conflicts resolved. This PR should be read for your review again @getusha

@melvin-bot melvin-bot bot requested a review from arosiclair September 2, 2024 16:33
@arosiclair arosiclair merged commit 73bcfea into Expensify:main Sep 2, 2024
17 of 23 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Sep 2, 2024

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Sep 2, 2024

🚀 Deployed to staging by https://github.com/arosiclair in version: 9.0.28-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Sep 3, 2024

🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.28-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants