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 receipts in chat #24235

Merged
merged 68 commits into from
Aug 21, 2023
Merged

Display receipts in chat #24235

merged 68 commits into from
Aug 21, 2023

Conversation

Li357
Copy link
Contributor

@Li357 Li357 commented Aug 7, 2023

Details

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/295245

We're bringing SmartScan receipts to NewDot!

Tests

Before testing and before the Auth/Web-E changes make it to staging, please pull my branches https://github.com/Expensify/Auth/pull/8494 and #24235 to test! Remember to rebuild Auth + restart.

Note that for all tests: adding money requests to an IOU report that already exists via Global Create creates an extra IOU report action item, because the reportID is not in the URL when going thru Global Create. This is not in scope here, but we can fix in a later PR. For everything except for Test 1 step 1, use the + button the chat to create requests.

Test 1

  1. Log into user A with no previous money requests with B
  2. Click on Global Create > Request Money
  3. Choose scan and upload an image
  4. Assign the request to another known user B (you've chatted with them before)
  5. Verify that a new Report Preview is created, with subtitle "Receipt" and headline "Scan in progress…"
  6. Verify that the Report Preview is a whisper with "Only visible to you"
  7. Verify that the local receipt image is immediately visible, but reloads to the remote image when the API responds
  8. Verify that clicking on the Report Preview navigates to the IOU Report
  9. Verify that in the IOU Report, the receipt also shows as "Receipt" and "Scan in progress…"
  10. Verify that clicking on the IOU action brings up the Money Request View with "Receipt scan in progress…" in the LHN and a status bar under the Header with "Scanning…" and "Only you can see this receipt when it's scanning. Check back later or enter the details now."
  11. Verify that clicking on the receipt image in this view opens up a modal with title "Receipt"
  12. Log into user B and verify that you cannot see the Report Preview in the Chat & IOU reports

Test 2

  1. Log back into user A
  2. Type in the Chat Report with the report preview
  3. Add a manual request
  4. Verify that the Report Preview comes to the front of the chat report
  5. Verify that the Report Preview has subtitle "2 requests, 1 scanning"
  6. Verify that the Report Preview is no longer a whisper
  7. Add two more receipts and verify that all three appear in the Report Preview with subtitle "4 requests, 3 scanning"
  8. Add another receipt and give it a description "Foobar" (for test 3), and verify that only the three most recent appear in the Report Preview, and a +1 indicator is shown on the last receipt image

Test 3

  1. Stay logged in as user A in NewDot
  2. Wait for the receipt to finish scanning
  3. Verify that the report preview is not longer a whisper
  4. Verify that the report preview subtitle is now "4 requests, 3 scanning"
  5. Verify that in the IOU report, the last receipt is no longer a whisper
  6. Verify that in the Money Request View, "Receipt scan in progress" is no longer in the LHN nor is there a status bar underneath the header
  • Verify that no errors appear in the JS console

Offline tests

Most functionality should work offline, since we optimistically create/update the report previews and IOU report actions. In particular:

Test 1: steps 0-10 on a new account C
Test 2: all steps

QA Steps

Same as manual tests above

  • 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
    • 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
Screen.Recording.2023-08-15.at.1.17.41.AM.mov
Screen.Recording.2023-08-15.at.2.02.01.AM.mov
Mobile Web - Chrome
Mobile Web - Safari
Simulator.Screen.Recording.-.iPhone.14.16.1.-.2023-08-16.at.16.44.07.mov
Desktop
Screen.Recording.2023-08-16.at.4.17.46.PM.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.16.1.-.2023-08-16.at.16.06.07.mp4
Android

@Li357 Li357 self-assigned this Aug 7, 2023
@Li357 Li357 changed the title Display receipts in chat [HOLD Web-E #38478] Display receipts in chat Aug 11, 2023
@mvtglobally
Copy link

@Li357 @luacmartins @mountiny Do we need to QA this one or no?
Screen Shot 2023-08-21 at 10 55 05 PM

@Li357
Copy link
Contributor Author

Li357 commented Aug 22, 2023

@mvtglobally I'll update this! QA is same as the listed steps under Tests

@Li357
Copy link
Contributor Author

Li357 commented Aug 22, 2023

@situchan This PR unblocks a lot of internal issues so I don't think a revert is good here. Let's fix these linked issues ASAP!

@shawnborton
Copy link
Contributor

Hey team - just a friendly reminder, when we're merging lots of UI changes like this, please please please tag the design team for review. I already see a few things we missed that will need to be fixed in a follow up PR.

For example, on the scan banner, why is the text on the right right-aligned?

Or on this screen, why are we using a full-width thumbnail?
image

cc @JmillsExpensify @trjExpensify

@Li357
Copy link
Contributor Author

Li357 commented Aug 22, 2023

Hey @shawnborton, sorry about missing the procedure here, will do moving forward. The screenshot is actually old before the width had been clarified, currently we show the receipt preview on web with a max width:

Screenshot 2023-08-22 at 9 57 58 AM

Would you be able to do a design review in this PR? I'm consolidating a few smaller issues there. I'm also technically OOO now but here so we can move this forward without any regressions for external commits.

@shawnborton
Copy link
Contributor

Yup, mind tagging me in the PR and I'll give it a look?

@dangrous
Copy link
Contributor

dangrous commented Aug 22, 2023

Hi! According to git bisect, this caused a Deploy Blocker here - since this is a big PR, I could use a hand figuring out what happened and what to fix, it looks like it's this commit:

commit 941d730532ec090e4e4e2f5d91d0388f1ac63864
Author: Andrew Li <andrewli@expensify.com>
Date:   Wed Aug 9 09:29:09 2023 -0400

    Fit images to container

 src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js   |  2 +-
 .../HTMLEngineProvider/HTMLRenderers/ImageRenderer.js         | 11 ++++++++---
 src/components/ReportActionItem/ReportPreview.js              |  7 ++++---
 src/components/ThumbnailImage.js                              |  8 +++++++-
 src/styles/styles.js                                          |  2 +-
 5 files changed, 21 insertions(+), 9 deletions(-)

EDIT: it's this line, adding the w100 and h100 styles.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀

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

isHovered={props.isHovered}
shouldUseCardBackground
/>
{requestMerchant && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Caused this regression: #25616

const isLastImage = index === numberOfShownImages - 1;
return (
<View
key={image}
Copy link
Contributor

Choose a reason for hiding this comment

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

If the image value is not a local file or image type, then the key may be duplicated (pdf, doc, html, etc), causing rendering issue

</>
)}
</View>
<Icon src={Expensicons.ArrowRight} />
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused #25692 as we forgot to add the fill colour of the above icon.

@luacmartins
Copy link
Contributor

This PR introduced this bug because we didn't wrap images without thumbnail in a pressable component

checkIfContextMenuActive: toggleContextMenuFromActiveReportAction,
}}
>
<OfflineWithFeedback pendingAction={props.action.pendingAction}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #26235

This line brought back wrapping MoneyRequestView in OfflineWithFeedback, which was removed in
#25399. This might be a mistake in merge conflict resolution.

This caused a double application of the opacity reduction effect.

@cubuspl42
Copy link
Contributor

Coming from #27697

It was missed that the "Receipt scan in progress…" message doesn't always display in the report preview

@@ -177,6 +185,14 @@ function IOUPreview(props) {
return message;
};

const getDisplayAmountText = () => {
Copy link
Member

Choose a reason for hiding this comment

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

Hi, we didn't handle offline behavior for this function. It defaulted to showing amount as $0.

#29048 (comment)

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.