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

[QBO Export] Implement offline pattern B for manual report exports #44733

Conversation

kosmydel
Copy link
Contributor

@kosmydel kosmydel commented Jul 2, 2024

Details

This is a follow-up issue that adds Offline patterns for manual report exports. Until the main PR is merged you can see changes from this PR only using this link.

Fixed Issues

$ #43040

Tests

Sucessful offline export

  1. Submit an expense report
  2. Log in as the workspace admin
  3. Approve the report
  4. Go offline
  5. 3-dot menu > Export > Quickbooks Online
  6. Verify a semi-transparent started exporting this report to QuickBooks Online... message shows
  7. Go online
  8. Verify the action becomes fully opaque
  9. Wait a few seconds
  10. Verify the action updates to exported this report to QuickBooks Online. [View out-of-pocket expenses].

Failed offline export

Prerequisites

  • Add a chart of account (category) to QBO that you can delete later

Steps

  1. Create a report with an expense
  2. Categorize the expense using the new QBO category
  3. Submit it
  4. Log in as the workspace admin and approve the report
  5. Log into QBO and deactivate the chart of account for the category (Menu > Transactions > Chart of accounts > {account} menu > Make inactive)
  6. Go offline in NewDot
  7. Export the report to QBO (3-dot menu > Export > Quickbooks Online)
  8. Verify a semi-transparent started exporting this report to QuickBooks Online... message shows
  9. Go online
  10. Verify the action becomes fully opaque
  11. Wait a few seconds
  12. Verify a report export error message is added the report

Offline tests

Same as Tests

QA Steps

Same as Tests

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
Android: mWeb Chrome
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-16.at.15.09.04.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-07-16.at.15.05.37.mov
MacOS: Desktop

Comment on lines 5156 to 5176
function buildOptimisticExportIntegrationAction(label = '', markedManually = false): OptimisticExportAction {
return {
reportActionID: NumberUtils.rand64(),
actionName: CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
actorAccountID: currentUserAccountID,
message: [],
person: [],
automatic: false,
avatar: getCurrentUserAvatar(),
created: DateUtils.getDBTime(),
shouldShow: true,
originalMessage: {
automaticAction: false,
label,
lastModified: DateUtils.getDBTime(),
markedManually,
},
};
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, @arosiclair could you have a look and confirm that this is the only action that I need to add when offline? The issue said that, but the backend sends a few more Onyx updates.

If this is the only action, do you know if it has all the required fields?

I managed to reverse-engineer it from the backend response, but it would be great to have confirmation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this should be the only new action added and the data looks good so far.

I updated the issue here btw. We'll still add this optimistic action, but the text needs to be different while it's optimistic. We should be able to control that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just want to make sure: we want to leave this action in the old dot report actions section?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that should be fine for now

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I have to work on the EXPORTINTEGRATION action in this PR first. So we should just control the copy in the new ExportIntegration component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this issue be held on #44930 as well?

Copy link
Contributor

@hungvu193 hungvu193 Jul 16, 2024

Choose a reason for hiding this comment

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

Seems #44930 is close to merge 👀

Comment on lines 3401 to 3408
exportedToIntegration: ({label, markedManually}: ExportedToIntegrationParams) => {
if (markedManually) {
// TODO: Verify translation - it was taken from the backend response, and it is needed here for the optimistic response
return `You marked this report as manually exported to`;
}
return `exported this report to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[label] ?? label}`;
},
exportInProgress: ({label}: ExportedToIntegrationParams) => `started exporting this report to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[label] ?? label}...`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those translations need to be verified.

@kosmydel
Copy link
Contributor Author

There might be something wrong with the backend responses. The manual export requests don't update automatically after reconnecting. After refreshing the page I can see 2 actions coming from the backend.

Screen.Recording.2024-07-16.at.13.13.31.mov

@kosmydel kosmydel marked this pull request as ready for review July 16, 2024 13:11
@kosmydel kosmydel requested review from a team as code owners July 16, 2024 13:11
@melvin-bot melvin-bot bot removed the request for review from a team July 16, 2024 13:11
Copy link

melvin-bot bot commented Jul 16, 2024

@hungvu193 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]

@melvin-bot melvin-bot bot requested a review from hungvu193 July 16, 2024 13:11
@hungvu193
Copy link
Contributor

Can you merge this with latest main? @kosmydel

@kosmydel
Copy link
Contributor Author

Can you merge this with latest main? @kosmydel

Yeah, I've already done it :D

@arosiclair
Copy link
Contributor

arosiclair commented Jul 16, 2024

We should wait for #44930 to get merged so that these actions display correctly.

There might be something wrong with the backend responses. The manual export requests don't update automatically after reconnecting. After refreshing the page I can see 2 actions coming from the backend.

I still need to draft changes to support this on the backend. I'll get started on that today

@arosiclair arosiclair changed the title [QBO Export] Implement offline pattern B for manual report exports [HOLD][QBO Export] Implement offline pattern B for manual report exports Jul 16, 2024
Copy link
Contributor

@hungvu193 hungvu193 left a comment

Choose a reason for hiding this comment

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

LGTM! (I can't upload few screenshots due to some internet connection issue, I'll update them later in the morning).

Update: Completed all the screenshots/videos.

@melvin-bot melvin-bot bot requested a review from arosiclair July 25, 2024 15:50
@hungvu193
Copy link
Contributor

There's an issue with Pusher data I think, the result of export data will never show up until you visit that report once again.
It was working fine yesterday when I first tested it.

Screen.Recording.2024-07-26.at.11.13.46.mov

@war-in
Copy link
Contributor

war-in commented Jul 26, 2024

cc @arosiclair 👆

@arosiclair
Copy link
Contributor

@hungvu193 you have to test with a QBO connection. Xero does not support pattern B yet. Also you should expect the export to succeed and the started exporting to QuickBooks Online... message should be replaced with the exported this report to QBO message instead of showing up as a separate one.

Can you retest?

@hungvu193
Copy link
Contributor

hungvu193 commented Jul 26, 2024

Ah yes, Xero export is working as expected

I mean sometimes it's working even with Xero. Let me test with QBO

Screen.Recording.2024-07-25.at.18.02.40.mov

@hungvu193
Copy link
Contributor

@arosiclair I've just tested with QBO, I can't receive Pusher update for export report result.

Screen.Recording.2024-07-26.at.21.29.54.mov

@hungvu193
Copy link
Contributor

Can you please trigger the build here?

@trjExpensify
Copy link
Contributor

Building.

Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/44733/index.html ❌ FAILED ❌
Android The QR code can't be generated, because the iOS build failed
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/44733/NewExpensify.dmg https://44733.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@arosiclair
Copy link
Contributor

I mean sometimes it's working even with Xero. Let me test with QBO

Pattern B is not working correctly if started... and exported messages appear separately here. I updated the test steps to verify that. Make sure that works correctly with QBO please 🙏

@arosiclair I've just tested with QBO, I can't receive Pusher update for export report result.

If it's still not exporting successfully, can you share the requestID for the Report_Export command? You can get it in the response from dev tools.

@hungvu193
Copy link
Contributor

If it's still not exporting successfully, can you share the requestID for the Report_Export command? You can get it in the response from dev tools.

Here you are: 8aa979e0ab3b85b2-HKG

Here's the cURL in case you need it:

cURL
curl 'https://dev.new.expensify.com:8082/api/Report_Export?' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary06cD0MPYlWlTh4x6' \
  -H 'Cookie: initialReferer=%28direct%29; browserGUID=653888c049509; mutiny.user.token=44271853-1d21-40d9-9708-52c3488dccc2; _gcl_au=1.1.1997638827.1716280514; _ga_GR0HGLT8QC=GS1.2.1716280514.5.1.1716280535.39.0.0; fs_cid=1.1; _ga_JN0QG4EC3H=GS1.2.1720511043.2.0.1720511043.60.0.0; AMCV_98CF678254E93B1B0A4C98A5%40AdobeOrg=179643557%7CMCMID%7C18503322733917679562200117914871702674%7CMCAAMLH-1721115844%7C3%7CMCAAMB-1721115844%7C6G1ynYcLPuiQxYZrsz_pkqfLG9yMXBpb2zX5dvJdYQJzPXImdj0y%7CMCOPTOUT-1720518244s%7CNONE%7CvVersion%7C5.5.0; _ga_PNQ04Q4SFF=GS1.2.1720665626.1.1.1720666987.60.0.0; _ga=GA1.1.1392566190.1709532684; onfido-web-sdk-analytics=4ece8e2a-feb6-4445-ae5d-92097385485b; cf_clearance=E.dN7s6jqZ0FJIRTRTV55Gnm2JcjSQ5QV98e3CInL4o-1721899523-1.0.1.1-hPZSaeqGbiv720b9H9oEOMaRx0kETiffiNtBfbVbGjtbbYatlZfWdkxRBWB1gEHeOBTE78oB6l_xGV9JTrSAEA; _clck=1brb4ho%7C2%7Cfnr%7C0%7C1640; _uetvid=ee01f610353b11ef8f28c919fee6a33f; _ga_6BR2QJRCCD=GS1.1.1721902395.17.0.1721902395.60.0.0; fs_uid=#o-1WN56P-na1#bf579a4d-f5be-46e8-8fed-4ffb247ea8a7:7cafb27f-ba85-484b-999e-324705d96274:1721964928589::1#a73a1961#/1749626460; __cf_bm=vpwUtixxTeWNmZLzBSTHTX4hdQY3qAV9XwiX4et3Cp4-1722217806-1.0.1.1-WFiYYn9VXtxbBgIw1sw.Ewx7bhrTMM1mYF6mCypC61o5PNrbCmop.Af4492qkoHvsZAItnUnQNeVnf2gh06d9w; _cfuvid=buXapMIr.uHwcS.MGtSQEceocwEd53k7eZoyApGULgk-1722217806724-0.0.1.1-604800000' \
  -H 'Origin: https://dev.new.expensify.com:8082' \
  -H 'Referer: https://dev.new.expensify.com:8082/r/6403319933559642' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw $'------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="reportIDList"\r\n\r\n6403319933559642\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="connectionName"\r\n\r\nquickbooksOnline\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="type"\r\n\r\nMANUAL\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="optimisticReportActions"\r\n\r\n{"6403319933559642":"5953812755179798095"}\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="apiRequestType"\r\n\r\nwrite\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="pusherSocketID"\r\n\r\n753965.1528538\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="shouldRetry"\r\n\r\ntrue\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="canCancel"\r\n\r\ntrue\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="authToken"\r\n\r\n491BBB6BE109CB52F429E640C1AF60BD166B92E96FC9A9E05CF0FC146F782D776ED6F8A6A61EB54FB5DE8FF11AB952F03D84E58A810878C2CA796DC3583C1318C1C90D3EA660BC03789373E4186592238838BB0F39C17E648DC66DACF74E78C71229DABDBFFA797D3C1ABDE7322FC2C25C423638BDCB15BF9178767E3FB141EF780076F1E53240F6919CA31514C3C2DC40ECA3A229CA9613CD52FD82E516C6F5580E33E2896DF9AE85BC0D6A08BA9D97930EF2CE3486BC2F66AFDBC8EB88B724D54E3EEDC50F5B386A991DEA63E7212EC370D16339749CBC910BBC164D7F23F6FAEB007A396C791E3339061CA351DDA4F933725E59CEA2C8A231DF45C3A61E5D79A5378D943524C6BC4F0EA1EB15BE00E9BCD615FF9C5E2E9D2D4A4F23F8DF5CC58F2DAFF1DA988D849E4B01176612C5373753119BB6BE269DE92D4165EC067272D8AFD8052945EC42F7E84552B6D172CF57EC8F7259EC978B428C774163C69D\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="referer"\r\n\r\necash\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="platform"\r\n\r\nweb\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="api_setCookie"\r\n\r\nfalse\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="email"\r\n\r\nvisaocuoitroi193+5@gmail.com\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="isFromDevEnv"\r\n\r\ntrue\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="appversion"\r\n\r\n9.0.12-0\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6\r\nContent-Disposition: form-data; name="clientUpdateID"\r\n\r\n731484111\r\n------WebKitFormBoundary06cD0MPYlWlTh4x6--\r\n'

@arosiclair
Copy link
Contributor

arosiclair commented Jul 29, 2024

I see

Could not find QuickBooks vendor

Hmm.. we're unable to find a QuickBooks vendor for visaocuoitroi193+5@gmail.com. Don't worry, just enable Automatic Entity Creation and you'll never run into this error again! Alternatively, you can resolve this issue by logging into QuickBooks, associating an email address with the appropriate vendor, and then exporting again

Are you able to sync your QBO connection successfully? Try to do it from OldDot (Settings > Workspaces > Group > {policy} > Connections). Try that and try following the instructions from the above error messages if it still doesn't work. If you're still having trouble, start a thread in #wave-collect and I'll help you debug though it's a little difficult with our timezone difference.

@hungvu193
Copy link
Contributor

Sure. Let me give it a try

@hungvu193
Copy link
Contributor

hungvu193 commented Jul 29, 2024

@arosiclair Awesome! I can export data to QBO successfully. I need to enable Automatically Create Entities from OldDot. I just wonder why we don't add that option into ND?

Screen.Recording.2024-07-29.at.22.37.21.mov

@hungvu193
Copy link
Contributor

so I think this one will be ready for your final review @arosiclair

@arosiclair arosiclair merged commit 914491a into Expensify:main Jul 29, 2024
18 checks passed
@OSBotify
Copy link
Contributor

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

@trjExpensify
Copy link
Contributor

I need to enable Automatically Create Entities from OldDot. I just wonder why we don't add that option into ND?

This setting should exist on ND under the Advanced tab. :)

@trjExpensify
Copy link
Contributor

I am curious why we aren't showing an error on export in the report comments though. Asked about that here.

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/roryabraham in version: 9.0.14-1 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@hungvu193
Copy link
Contributor

I am curious why we aren't showing an error on export in the report comments though. Asked about that here.

It threw errors with other accounts, but I'm not sure why it didn't with this account, I also can't even log in to OldDot with this account.

@arosiclair
Copy link
Contributor

I am curious why we aren't showing an error on export in the report comments though. Asked about that here.

I see it here:

image

@trjExpensify
Copy link
Contributor

Ah okay, cool. Sounded like from Hans that wasn't showing.

@roryabraham
Copy link
Contributor

Just as a heads-up to everyone. This one was a QA fail: #46436 (comment). It wasn't reverted because it doesn't appear to cause a regression. It just didn't appear to fix the original issue.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.14-6 🚀

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants