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

Handle the error with journal entry when tax is enabled #41520

Conversation

teneeto
Copy link
Contributor

@teneeto teneeto commented May 2, 2024

Details

This PR allows to warn the user of the error that happens when Journal Entry is selected as the out-of-pocket expense export destination while tax is enabled.

Screen.Recording.2024-05-02.at.17.55.11.mov

Fixed Issues

$: 41042
PROPOSAL: issuecomment

Tests

Case When Journal is selected as Export entity

  1. Set up QBO - UK QBO account.
  2. select Export settings
  3. select Export out-of-pocket expenses as
  4. select Export as and choose Journal as the export entity type.
  5. go back to qbo main menu and select Import settings.
  6. Then select Taxes
    Expectation: when Journal is selected as an export entity type, you should not be able to enable taxes, and there should be a hint text about why you can't enable taxes.

Case When Tax is enabled

  1. From QBO settings menu, select Import settings
  2. select Taxes and toggle on import.
  3. go back to QBO setting menu and select Export settings
  4. select Export out-of-pocket expenses as
  5. select Export as

Expectation: Notice how you can't find Journal amongst the export options and there should be a hint text about why you don't have the Journal option.

  • Verify that no errors appear in the JS console

Offline tests

Case When Journal is selected as Export entity

  1. Set up QBO - UK QBO account..
  2. select Export settings
  3. select Export out-of-pocket expenses as
  4. select Export as and choose Journal as the export entity type.
  5. go back to qbo main menu and select Import settings.
  6. Then select Taxes
    Expectation: when Journal is selected as an export entity type, you should not be able to enable taxes, and there should be a hint text about why you can't enable taxes.

Case When Tax is enabled

  1. From QBO settings menu, select Import settings
  2. select Taxes and toggle on import.
  3. go back to QBO setting menu and select Export settings
  4. select Export out-of-pocket expenses as
  5. select Export as

Expectation: Notice how you can't find Journal amongst the export options and there should be a hint text about why you don't have the Journal option.

QA Steps

Case When Journal is selected as Export entity

  1. Set up QBO - UK QBO account..
  2. select Export settings
  3. select Export out-of-pocket expenses as
  4. select Export as and choose Journal as the export entity type.
  5. go back to qbo main menu and select Import settings.
  6. Then select Taxes
    Expectation: when Journal is selected as an export entity type, you should not be able to enable taxes, and there should be a hint text about why you can't enable taxes.

Case When Tax is enabled

  1. From QBO settings menu, select Import settings
  2. select Taxes and toggle on import.
  3. go back to QBO setting menu and select Export settings
  4. select Export out-of-pocket expenses as
  5. select Export as

Expectation: Notice how you can't find Journal amongst the export options and there should be a hint text about why you don't have the Journal option.

  • 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

MacOS: Chrome / Safari
Screen.Recording.2024-05-02.at.17.55.11.mov
iOS: Native
Android: Native
Android: mWeb Chrome
iOS: mWeb Safari
MacOS: Desktop

@teneeto teneeto requested a review from a team as a code owner May 2, 2024 17:11
@teneeto teneeto changed the title Handle the error with journal entry when tax is enable Handle the error with journal entry when tax is enabled May 2, 2024
@melvin-bot melvin-bot bot requested review from amyevans and removed request for a team May 2, 2024 17:11
Copy link

melvin-bot bot commented May 2, 2024

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

@teneeto
Copy link
Contributor Author

teneeto commented May 2, 2024

@pecanoro @Gonals a few translations here for your scrutiny 🧐.

@amyevans amyevans requested review from rojiphil and removed request for amyevans May 2, 2024 19:17
@amyevans
Copy link
Contributor

amyevans commented May 2, 2024

Assigning @rojiphil for review since that's who it looks like it should be based on the linked issue, lmk if not!

@teneeto
Copy link
Contributor Author

teneeto commented May 2, 2024

@trjExpensify @hayata-suenaga mentioning you here too. PR is ready.

@hayata-suenaga hayata-suenaga self-requested a review May 2, 2024 20:23
@trjExpensify
Copy link
Contributor

Why is there an error here? 🤔

image

In the frame before, you showed Taxes as being not imported because Journal Entry is selected:

image

@teneeto
Copy link
Contributor Author

teneeto commented May 2, 2024

@trjExpensify That error is there for all the fields that has error or brick road Indicator and that's because I'm not connected to QBO. I believe if you test on your end, you won't find those.

@trjExpensify
Copy link
Contributor

@trjExpensify That error is there for all the fields that has error or brick road Indicator and that's because I'm not connected to QBO. I believe if you test on your end, you won't find those.

I don't understand this comment, sorry. I'm going to create a build.

@trjExpensify
Copy link
Contributor

Here are the two screens we're expecting to see.

Case: When Journal Entry is selected for exporting out of pocket expenses

  1. Set up QBO.
  2. select Export settings
  3. select Export out-of-pocket expenses as
  4. select Export as and choose Journal Entry as the export entity type.
  5. go back to qbo main menu and select Import settings.
  6. Then select Taxes

Expectation: when Journal Entry is selected as an export entity type, you should not be able to import taxes, and there should be a hint text about why you can't import taxes.

image

Case: When Taxes are imported, you can't export as Journal Entry

  1. From QBO settings menu, select Import settings
  2. select Taxes and toggle on import.
  3. go back to QBO setting menu and select Export settings
  4. select Export out-of-pocket expenses as
  5. select Export as
  6. Expectation: Notice how you can't find Journal Entry amongst the export options and there should be a hint text about why you don't have the Journal Entry option.
image

@teneeto
Copy link
Contributor Author

teneeto commented May 3, 2024

@trjExpensify That error is there for all the fields that has error or brick road Indicator and that's because I'm not connected to QBO. I believe if you test on your end, you won't find those.

I don't understand this comment, sorry. I'm going to create a build.

O Apologies for getting you lost there. what i meant was, that error was showing because I did not setup QBO on my local. I bypassed to make that fix. But if tested on real data or live it should work as expected without the error.

@teneeto
Copy link
Contributor Author

teneeto commented May 3, 2024

Here are the two screens we're expecting to see.

Case: When Journal Entry is selected for exporting out of pocket expenses

  1. Set up QBO.
  2. select Export settings
  3. select Export out-of-pocket expenses as
  4. select Export as and choose Journal Entry as the export entity type.
  5. go back to qbo main menu and select Import settings.
  6. Then select Taxes

Expectation: when Journal Entry is selected as an export entity type, you should not be able to import taxes, and there should be a hint text about why you can't import taxes.

image **Case: When Taxes are imported, you can't export as Journal Entry**
  1. From QBO settings menu, select Import settings
  2. select Taxes and toggle on import.
  3. go back to QBO setting menu and select Export settings
  4. select Export out-of-pocket expenses as
  5. select Export as
  6. Expectation: Notice how you can't find Journal Entry amongst the export options and there should be a hint text about why you don't have the Journal Entry option.
image

And yes! it should work this way.

Copy link
Contributor

github-actions bot commented May 3, 2024

@hayata-suenaga
Copy link
Contributor

hayata-suenaga commented May 6, 2024

and in parallel, we can try to do something in the backend so it doesn't happen.

If enabled, why don’t we disable the syncTax when we update the policy connection configuration to set Journal entry ?

Turning off the tax import on the backend when the Journal Entry is selected introduces a new pattern that we have not yet considered. This might confuse users, as they do not anticipate these configuration options changing simultaneously.

There is an existing error message that has not been used yet. Could it be the one that @teneeto used in the earlier commits of this PR? The message was added in this PR. I suggest we use it now in the event of a misconfiguration.

Screenshot 2024-05-06 at 4 55 22 PM

cc: @aldo-expensify and @trjExpensify

PS: @trjExpensify, we're discussing this very rare case when the misconfiguration does happen.

@trjExpensify
Copy link
Contributor

I suggest we use it now in the event of a misconfiguration.

I think that sounds reasonable for this edge case. Let's ensure that we apply the "red brick road" to lead to this error though. I.e

  • Red dot on the settings avatar in the bottom tabs
  • Red dot on the Workspaces row in the Settings LHN menu
  • Red dot on the workspace in the list that contains an error
  • Red dot on the Accounting row in the workspace settings LHN menu
  • Red dot on the Export row in the QBO config card
  • Red dot on the Export out of pocket expenses as row
  • Red dot and error message in-line on the Export as page with the incorrect export method selected

@pecanoro
Copy link
Contributor

pecanoro commented May 9, 2024

I got a bit lost on the next steps here. Do we need to update the PR to handle the previous cases that were discussed?

@hayata-suenaga
Copy link
Contributor

by "previous case", do you mean this one?

@hayata-suenaga
Copy link
Contributor

I'll do a more closer code review today

@hayata-suenaga
Copy link
Contributor

I tested this PR on my local machine and it tested well.

The Tax toggle is locked and the hint text is displayed

Screenshot 2024-05-09 at 6 18 28 PM

The Journal Entry doesn't show up in the list of options when the Tax is enabled

Screenshot 2024-05-09 at 6 20 00 PM

@rojiphil
Copy link
Contributor

If enabled, why don’t we disable the syncTax when we update the policy connection configuration to set Journal entry ?

Turning off the tax import on the backend when the Journal Entry is selected introduces a new pattern that we have not yet considered. This might confuse users, as they do not anticipate these configuration options changing simultaneously.

Got it. Thanks @hayata-suenaga

@rojiphil
Copy link
Contributor

Usually, this isn't problematic as users are unable to select Journal Entry when the tax import is enabled. However, issues may occur when the device is offline or when users alter specific options on Expensify Classic and others on New Expensify.

I haven’t reviewed the code from this perspective yet. I will do this today and provide an update.

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

Thanks @teneeto. The recent changes work well.
But I have left some comments for your consideration based on the review from the perspective mentioned here,

/>
</View>
</OfflineWithFeedback>
</View>
{isJournalExportEntity && <Text style={[styles.mutedNormalTextLabel, styles.pt2]}>{translate('workspace.qbo.taxesJournalEntrySwitchNote')}</Text>}
Copy link
Contributor

Choose a reason for hiding this comment

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

The hint text does not seem right for the above-mentioned scenario i.e. when the syncTax is true
Journal Entry export is set).
A separate hint text may be better here for this specific scenario
What do you think?

Copy link
Contributor

@hayata-suenaga hayata-suenaga May 10, 2024

Choose a reason for hiding this comment

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

Something like !syncTax && isJournalExportEntity could solve this problem.

Yes I agree.

@teneeto, could you remind me if we have an error message on the frontend side for the rare case of Journal Entry is selected while the syncTax is on (when the configuration was changed in Expensify Classic, etc).

Copy link
Contributor

@hayata-suenaga hayata-suenaga May 10, 2024

Choose a reason for hiding this comment

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

@teneeto, could you remind me if we have an error message on the frontend side for the rare case of Journal Entry is selected while the syncTax is one (when the configuration was changed in Expensify Classic, etc).

Checked the code, and we display this error message when the above misconfiguration happens here. Should we do the same for the Tax toggle, too on the QuickbooksTaxesPage? (instead of displaying the hint text)?

Screenshot 2024-05-10 at 12 09 15 PM

Copy link
Contributor

@hayata-suenaga hayata-suenaga May 10, 2024

Choose a reason for hiding this comment

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

@teneeto, or do we already have an error message for the above case, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me confirm

Copy link
Contributor

Choose a reason for hiding this comment

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

There are no error fields here. should we add here?

Please see the comment below 😄

we will probably move the error handling to the backend. We don't have to do this on the front end. Please ignore this comment ⬇️

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any change I'll need to make?

Thank you for reminding where the UI copy came from. I agree with @rojiphil on the following point:

The hint text does not seem right for the above-mentioned scenario i.e. when the syncTax is true
Journal Entry export is set).

I think we should have the same condition as what @rojiphil suggested -> !syncTax && isJournalExportEntity to display this hint message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

Choose a reason for hiding this comment

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

@teneeto, can you modify the code according to my suggestion here?

What the user needs to do in this case (!syncTax && isJournalExportEntity) is to toggle off the Switch and the hint text can be misleading

Copy link
Contributor

Choose a reason for hiding this comment

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

it's rare case anyway, so I gonna address this change when I make a backend change to handle errors on the backend side 👍

@hayata-suenaga
Copy link
Contributor

hayata-suenaga commented May 10, 2024

@teneeto, could you update the testing steps in the OP to mention that the tester needs to use a UK QBO account?

@hayata-suenaga
Copy link
Contributor

hayata-suenaga commented May 13, 2024

I'm not sure if we should handle these errors in the front end. If we're going to display errors, we have to create the complete RBR flow (Tom explained this here).

Screenshot 2024-05-13 at 4 24 08 PM Screenshot 2024-05-13 at 4 24 45 PM

For now, I'd say we don't account for the edges cases that can happen because the user changes some configurations on Expensify Classics). Let's rely on the front end safeguard for now.

We can follow up with the backend change (return an error if the invalid configuration combination is attempted to made). And we can display the error returned from the backend following the RBR pattern that Tom described here)

I created a follow-up backend issue here (internal link)

@rojiphil
Copy link
Contributor

Working on the checklist now

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

LGTM. And tests well too.

Copy link

melvin-bot bot commented May 15, 2024

🎯 @rojiphil, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #42187.

@hayata-suenaga hayata-suenaga merged commit b839bdf into Expensify:main May 15, 2024
20 of 25 checks passed
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/hayata-suenaga in version: 1.4.75-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.75-1 🚀

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