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

Display Smartscan errors #26155

Merged
merged 19 commits into from
Sep 1, 2023
Merged

Display Smartscan errors #26155

merged 19 commits into from
Sep 1, 2023

Conversation

Gonals
Copy link
Contributor

@Gonals Gonals commented Aug 29, 2023

cc @mountiny

Details

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/295256
PROPOSAL:

Tests

  1. Set up Smartscan if you haven't yet. I'd recommend clearing any existing receipts in there to make this easier.
  2. Run bwm.sh
  3. Create a new receipt money request from newDot by going to + -> Request Money -> Scan and sending a random image. Make sure to choose a worskpace, as we'll be disabling Scan receipts for IOUs soon. A "Smartscanning" transaction should be created:
Screenshot 2023-08-23 at 11 49 17 AM
  1. Wait for a bit for bwm to do its thing (you are waiting for SmartScan?receiptID=XXX).
  2. Log into expensify.com.dev/expensiworks/
  3. Find the receipt you just uploaded (if you cleared up the other ones, it'll be the only one!) and populate all fields except for the merchant.
  4. Wait for another bit for bwm to do its thing
  5. Fields should be populates in App, and the merchant set to "Unknown merchant" and with a visible error:
Screenshot 2023-08-25 at 10 37 39 AM
  1. The redDot should also be visible in the money request preview:
Screenshot 2023-08-29 at 3 18 20 PM

Report preview:
Screenshot 2023-08-29 at 3 18 27 PM

And LHN (In the parent chat):
Screenshot 2023-08-29 at 3 18 32 PM

  1. Edit the merchant:
Screenshot 2023-08-29 at 3 18 59 PM
  1. The error should disappear from everywhere:
Screenshot 2023-08-29 at 3 19 21 PM
  1. Try with the amount instead of the merchant.
  • Verify that no errors appear in the JS console

Offline tests

None

QA Steps

Testing receipts to smartscan is going to be hard, as you'll need to smartscan the receipt yourself... and I'm not sure this is doable. You can set yourself to QA smartscan following this instructions, but it may be hard to get the right receipt.

Alternatively, maybe you can just upload an image with instructions as a receipt? Or a receipt with no merchant visible! That should get the smartscanner to skip it!
Once that is done:

  1. Create a new receipt money request from newDot by going to + -> Request Money -> receipt and sending a random image. Make sure to choose a worskpace, as we'll be disabling Scan receipts for IOUs soon. A "Smartscanning" transaction should be created.
  2. After a bit, find that receipt in smartscan and populate all field except the merchant (indicate unknown merchant) (I really think this is not feasible)
  3. Fields should be populates in App, and the merchant set to "Unknown merchant" and with a visible error:
Screenshot 2023-08-25 at 10 37 39 AM
  1. The redDot should also be visible in the money request preview:
Screenshot 2023-08-29 at 3 18 20 PM

Report preview:
Screenshot 2023-08-29 at 3 18 27 PM

And LHN (In the parent chat):
Screenshot 2023-08-29 at 3 18 32 PM

  1. Edit the merchant:
Screenshot 2023-08-29 at 3 18 59 PM
  1. The error should disappear from everywhere:
Screenshot 2023-08-29 at 3 19 21 PM
  1. Try with the amount instead of the merchant.
  • 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 / Chrome
    • iOS / native
    • iOS / 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 approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • 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 a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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(themeColors.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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web Screenshot 2023-08-29 at 3 18 44 PM
Mobile Web - Chrome Screenshot 2023-08-30 at 12 59 10 PM Screenshot 2023-08-30 at 12 59 21 PM Screenshot 2023-08-30 at 12 59 30 PM
Mobile Web - Safari Screenshot 2023-08-30 at 12 26 51 PM Screenshot 2023-08-30 at 12 26 58 PM Screenshot 2023-08-30 at 12 27 04 PM
Desktop Screenshot 2023-08-30 at 11 20 36 AM
iOS Screenshot 2023-08-30 at 12 23 04 PM Screenshot 2023-08-30 at 12 23 15 PM Screenshot 2023-08-30 at 12 23 27 PM
Android Screenshot 2023-08-30 at 12 46 06 PM Screenshot 2023-08-30 at 12 46 14 PM Screenshot 2023-08-30 at 12 46 21 PM

@Gonals Gonals requested a review from a team as a code owner August 29, 2023 09:18
@Gonals Gonals self-assigned this Aug 29, 2023
@melvin-bot melvin-bot bot removed the request for review from a team August 29, 2023 09:18
@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

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

@Gonals Gonals changed the title [WIP] Display Smartscan errors Display Smartscan errors Aug 29, 2023
@Gonals
Copy link
Contributor Author

Gonals commented Aug 29, 2023

Adding screencaptures tomorrow

@tylerkaraszewski
Copy link
Contributor

tylerkaraszewski commented Aug 29, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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
    • 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 approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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(themeColors.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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web Screenshot 2023-08-29 at 15 06 05
Screen.Recording.2023-09-01.at.3.31.09.PM.mov
Screen.Recording.2023-09-01.at.3.40.39.PM.mov
Mobile Web - Chrome
Screen.Recording.2023-09-01.at.3.27.29.PM.mov
Mobile Web - Safari
Screen.Recording.2023-09-01.at.3.24.45.PM.mov
Desktop
Screen.Recording.2023-09-01.at.3.09.54.PM.mov
iOS
Screen.Recording.2023-09-01.at.3.15.50.PM.mov
Android
Screen.Recording.2023-09-01.at.3.29.42.PM.mov

@tylerkaraszewski
Copy link
Contributor

On updating the merchant, the LHN isn't updating to remove the red dot:
Screenshot 2023-08-29 at 15 17 02

@tylerkaraszewski
Copy link
Contributor

Hmm, I left this open and came back to it after a while and it seems to have resolved itself. I'm not sure why it took at least several minutes, though.
Screenshot 2023-08-29 at 16 05 58

@Gonals
Copy link
Contributor Author

Gonals commented Aug 30, 2023

Hmm, I left this open and came back to it after a while and it seems to have resolved itself. I'm not sure why it took at least several minutes, though. Screenshot 2023-08-29 at 16 05 58

Hmm. Weird. I've ran the flow a couple of times and it goes away for me in a couple of seconds or so 🤷

@Gonals
Copy link
Contributor Author

Gonals commented Aug 30, 2023

Hmm, I left this open and came back to it after a while and it seems to have resolved itself. I'm not sure why it took at least several minutes, though. Screenshot 2023-08-29 at 16 05 58

Hmm. Weird. I've ran the flow a couple of times and it goes away for me in a couple of seconds or so 🤷

I changed a bit how this works, so it may be faster/better now 😁

@Gonals
Copy link
Contributor Author

Gonals commented Aug 30, 2023

Screenshots added!

Copy link
Contributor

@cristipaval cristipaval left a comment

Choose a reason for hiding this comment

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

Code LGTM. Started testing but something is borked in my dev env with Expensiworks. I'll pause this for now as @tylerkaraszewski said he's going to continue testing this soon

@tylerkaraszewski
Copy link
Contributor

I'm working on it again. Currently seeing a negative value for the amount:
Screenshot 2023-08-30 at 14 22 23

@tylerkaraszewski
Copy link
Contributor

Looks like @MariaHCD ran through this all last night (thanks!) and filled out the remainder of the checklist, so I'm just going to do some testing on one or two platforms and if that looks OK, merge.

@tylerkaraszewski
Copy link
Contributor

Seems to be working OK on web. Still a bit of slowness but I'm letting that pass. Going to test on iOS.

Screenshot 2023-09-01 at 09 24 32

@tylerkaraszewski
Copy link
Contributor

iOS seems to be resolving this OK. I'm going to approve and merge.

Simulator Screenshot - iPhone SE (3rd generation) - 2023-09-01 at 10 19 46

@tylerkaraszewski tylerkaraszewski merged commit 28a31b8 into main Sep 1, 2023
15 checks passed
@tylerkaraszewski tylerkaraszewski deleted the alberto-smartErrors branch September 1, 2023 17:21
@OSBotify
Copy link
Contributor

OSBotify commented Sep 1, 2023

✋ 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 1, 2023

🚀 Deployed to staging by https://github.com/tylerkaraszewski in version: 1.3.62-0 🚀

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

* @returns {Boolean}
*/
function hasMissingSmartscanFields(transaction) {
return hasReceipt(transaction) && !isReceiptBeingScanned(transaction) && !areModifiedFieldsPopulated(transaction);
Copy link
Contributor

Choose a reason for hiding this comment

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

!isReceiptBeingScanned involves OPEN status as well as SCANFAILED, SCANCOMPLETE,
Should we show RBR for "OPEN" status?

Copy link
Contributor

Choose a reason for hiding this comment

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

!isReceiptBeingScanned involves OPEN status as well as SCANFAILED, SCANCOMPLETE

Could you clarify this? isReceiptBeingScanned checks for SCANFAILED and SCANCOMPLETE

function isReceiptBeingScanned(transaction) {
return _.contains([CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING], transaction.receipt.state);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

According to this function, !isReceiptBeingScanned includes every status that isn't in CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING].

Copy link
Contributor

Choose a reason for hiding this comment

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

So hasMissingSmartscanFields can return true if OPEN status because isReceiptBeingScanned is false

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not saying isReceiptBeingScanned is wrong. It's correct function.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I am concerned is why should we show RBR when "OPEN" status?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, thanks for clarifying! So I think if we have any missing fields (even if the receipt is in the OPEN state), we would want to show the RBR to highlight any missing fields to the user

@MariaHCD
Copy link
Contributor

MariaHCD commented Sep 4, 2023

Coming from https://github.com/Expensify/Web-Expensify/pull/38582#issuecomment-1703609122

The RBR still shows even though the merchant, created and amount have been smartscanned.

Tested on staging and it looks like the modifiedAmount and modifiedCreated fields are not set but the state is SCANCOMPLETE so hasMissingSmartscanFields evaluates to true and we show the RBR:

function areModifiedFieldsPopulated(transaction) {
return transaction.modifiedMerchant !== CONST.TRANSACTION.UNKNOWN_MERCHANT && transaction.modifiedAmount !== 0 && transaction.modifiedCreated !== '';
}

Screen.Recording.2023-09-04.at.11.33.32.AM.mov
Screenshot 2023-09-04 at 11 35 59 AM

cc: @Gonals, is it possible the modified fields are not set when the scan completes?

@mountiny
Copy link
Contributor

mountiny commented Sep 4, 2023

Yeah so for Expense report scans (not IOU), we use the transaction::update, which uses UpdateTranscation and we use the updateOriginal == true https://github.com/Expensify/Auth/blob/1106cb1e48ef2cfcc456cca4fb939277af43e433/auth/command/UpdateTransaction.cpp#L156 here so we edit the original fields

For IOUs we use the EditMoneyRequest and that always updates the modified fields

@MariaHCD
Copy link
Contributor

MariaHCD commented Sep 4, 2023

Oh, thanks for pointing that out! What is the reason behind setting updateOriginal == true?

@mountiny
Copy link
Contributor

mountiny commented Sep 4, 2023

Thats how its was for years 😅

@Gonals
Copy link
Contributor Author

Gonals commented Sep 4, 2023

Hmmm. We should probably be consistent here. @mountiny, since you also touched this. Anything agains using Auth::editMoneyRequest for Workspace money requests too? (we can just check it is a free policy, I think)

@mountiny
Copy link
Contributor

mountiny commented Sep 4, 2023

@Gonals This is for all smartscans though right? I dont think the command is fully ocmpatible with everythign we need for oldDot smartscan

@Gonals
Copy link
Contributor Author

Gonals commented Sep 4, 2023

Well, not quite, it'll be for smartscans for Free policies. Those are just Workspaces, so it should just be newdot stuff, I think.

@Gonals
Copy link
Contributor Author

Gonals commented Sep 4, 2023

In any case, for now, I'll change the logic in the frontend to check all fields, as it is the safest option now that we are close to the deadline

@Gonals Gonals mentioned this pull request Sep 4, 2023
59 tasks
@OSBotify
Copy link
Contributor

OSBotify commented Sep 4, 2023

🚀 Deployed to production by https://github.com/mountiny in version: 1.3.62-4 🚀

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

if (hasReceipt) {
receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(transaction.receipt.source, transaction.filename);
hasErrors = TransactionUtils.hasMissingSmartscanFields(transaction);
Copy link
Contributor

Choose a reason for hiding this comment

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

We only needed to show the error if the user was able to edit this report. This later caused #27333

@@ -115,11 +116,12 @@ function ReportPreview(props) {
const numberOfScanningReceipts = _.filter(transactionsWithReceipts, (transaction) => TransactionUtils.isReceiptBeingScanned(transaction)).length;
const hasReceipts = transactionsWithReceipts.length > 0;
const isScanning = hasReceipts && ReportUtils.areAllRequestsBeingSmartScanned(props.iouReportID, props.action);
const hasErrors = hasReceipts && ReportUtils.hasMissingSmartscanFields(props.iouReportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

This component hasn't subscribed to Onyx transactions collection, so if there is any update in related Onyx transactions collection, it won't cause re-render here. Causing this bug: #32256

@@ -86,8 +86,10 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, trans

const hasReceipt = TransactionUtils.hasReceipt(transaction);
let receiptURIs;
let hasErrors = false;
if (hasReceipt) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Gonals The hasReceipt aslo return true in case of manual request with attached receipt. So we want to show the error if the request is manual request with the attached receipt as well, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we smartscan in those cases

Copy link
Contributor

@dukenv0307 dukenv0307 Jan 30, 2024

Choose a reason for hiding this comment

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

So rather than using hasReceipt (line 90), we should use something like isScanRequest (a way to differentiate manual requests with an attached receipt from a smartscan request), right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because using hasReceipt leads to the bug #34997

Copy link
Contributor Author

@Gonals Gonals Jan 31, 2024

Choose a reason for hiding this comment

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

That seems reasonable, yes.

I think this was added before we implemented the functionality to attach receipts to manual requests, so that wasn't a problem at the time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I would return anything new from the server (especially since isScanRequest isn't something stored in the database). The proper way to know if a receipt was smartscanned is if the receipt has one of the CONST.IOU.RECEIPT_STATE states. I think TransactionUtils.hasReceipt(transaction); should be updated to look at that instead. Can you look into doing that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I am thinking that we maybe need two functions...

  • TransactionUtils.hasAttachment()
  • TransactionUtils.hasReceipt()

This would cover both cases and be more explicit for cases like this which are only meant to handle one case.

Copy link
Contributor

@dukenv0307 dukenv0307 Feb 1, 2024

Choose a reason for hiding this comment

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

@tgolen

to know if a receipt was smartscanned

Perhaps you misunderstood my point. I mean that we need to differentiate manual requests with an attached receipt from a smartscan request as we did in FE side:

function isScanRequest(transaction: Transaction): boolean {
// This is used during the request creation flow before the transaction has been saved to the server

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, the backend already has several methods that are similar to that. I still don't know that I am following this discussion completely but from the way I see it, the FE code for isScanRequest() needs to be refactored to account for the difference between a smartscan request and a manual request with attachment.

What does the backend have to do with it?

Copy link
Contributor

Choose a reason for hiding this comment

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

The check for errors is done only when there is receipt and that caused #34997

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.