Skip to content

[Better Expense Report View] Expense Report Preview #58479

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

Conversation

Guccio163
Copy link
Contributor

@Guccio163 Guccio163 commented Mar 14, 2025

Explanation of Change

This PR introduces MoneyRequestReportPreview - essentially designed to replace ReportPreview (at least in most scenarios). Since some parts of logic are the same as in ReportPreview, there are parts of code already proven to work - there is a comment left by me to help with navigating that.

This isn't a final product, since there are still couple of issues to work over, but can be handled in follow-ups - this PR is already quite big. Some of the things that are still to be done:

  1. Navigation to the MoneyRequestReportView on pressing the component.
  2. Logic for producing correct RBR messages (currently 'Review required' left as a placeholder)
  3. Fixing a bug blocking Carousel from turning when inside Report Actions list on web (which is why test steps only include navigation through buttons and swiping on native), fixing paging on web too (absence visible on mobile webs)

Fixed Issues

$ #57507
PROPOSAL:

Tests

  1. Check if 'checkmark` icon on the right of the title is visible when previewing settled report.
  2. Check if 'thumbs up` icon on the right of the title is visible when previewing approved report.
  3. Check if RBR with 'Review required' message is visible below title when previewing report with an error.
  4. a)Wide screen (top-right corner arrows visible)
    Click right/left arrows to navigate between transactions.
    b) Narrow screen (dots below transactions carousel visible)
    Click on the dots to navigate to exact transactions.
  5. In both scenarios check if all transactions are reachable and if there are more than 10 transactions, that there is a '+[surplus] more' item at the end.
  6. Check if you can swipe the transactions (only on android/iOS)
  7. Check if there is approve/review/pay/... button visible at the bottom of the component if the report should have one.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

"Same as tests"

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that 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 used JaimeGPT to get English > Spanish translation. I then posted it 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.ts 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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.mov
Android: mWeb Chrome
android-mWeb.mov
iOS: Native
Screen.Recording.2025-03-31.at.14.50.53.mov
iOS: mWeb Safari
Screen.Recording.2025-03-31.at.14.54.35.mov
MacOS: Chrome / Safari
Screen.Recording.2025-03-31.at.14.43.54.mov
MacOS: Desktop
Screen.Recording.2025-03-31.at.15.22.53.mov

@Guccio163
Copy link
Contributor Author

Hi, I'm creating this draft so you can overview how it goes forward; there are still some things to be done: retrieving correct RBR messages, working left/right arrows, mobile navigation dots and standardising the styling - they are still in the work in progress category.

There are also 2 problematic issues, but they can potentially be handled a little bit later:

  1. The nested flatlist doesn't want to scroll on web when inside inverted flatlist.
  2. The flatlist with paging enabled doesn't let us set margin/padding to flow over, it forces elements to the far left position.

I consulted both od these issues with colleagues from SWM and we couldn't find a plausible solution, so I left them for now not to spend more time on that.

Feel free to let me know what do you think, just keep in mind I'm aware that current state is still some way from finished ;)

@Guccio163
Copy link
Contributor Author

Hi, I'm in a process of restyling and I stumbled over this part of code in spacing.ts:

  mhv5: {
      marginVertical: -20,
  },

  mhv8: {
      marginVertical: -32,
  },

  mhv12: {
      marginVertical: -48,
  },

From what I've seen the common rule is to add n for negative , so shouldn't the names be mvnNumber instead of mhvNumber ?

@allgandalf
Copy link
Contributor

Please assign this PR to me for review

@Guccio163
Copy link
Contributor Author

Guccio163 commented Mar 21, 2025

Hi, this PR is ready for the first reviews, but keep in mind there are still couple of aspects to work on:

  • Chaining TransactionPreview with this component // DONE by Jakub Korytko
  • Navigation to the Money Request Report View page // Blocked
  • Specifying and implementing logic behind left arrow button, since it's incomplete right now // DONE
  • Specifying and implementing logic behind extracting report-specific errors to be seen in report-level RBR
  • Fixing 'Nested Inverted Flatlists' bug (Previously seen only on web and worked fine on mobile, but since I couldn't build today I couldn't check) // Probably follow-up
  • Implementing tests // DONE by Jakub Korytko
  • Fixing component's and approve button's widths // DONE by Jakub Korytko

These are the main issues to take care for now, potentially can be handled in follow-ups.

Important: This component isn't incorporated in the app yet, the main place you can see it is storybook. Probably should work about fine (but not scrolling due to inverted-nested bug) when put on the ReportPreview place.

@Guccio163 Guccio163 marked this pull request as ready for review March 21, 2025 15:58
@Guccio163 Guccio163 requested review from a team as code owners March 21, 2025 15:58
@melvin-bot melvin-bot bot requested review from DylanDylann and removed request for a team March 21, 2025 15:58
Copy link

melvin-bot bot commented Mar 21, 2025

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

@trjExpensify
Copy link
Contributor

I think @allgandalf is going to take this while you work on reviewing the others, @DylanDylann.

@luacmartins luacmartins requested review from allgandalf and removed request for DylanDylann March 21, 2025 16:23
Copy link
Contributor

github-actions bot commented Apr 1, 2025

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

Android 🤖 iOS 🍎
Android 🤖🔄 iOS 🍎🔄
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/58479-hybrid/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/58479-hybrid/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/58479/NewExpensify.dmg https://58479.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@shawnborton
Copy link
Contributor

Very small nitpick we can fix as a follow up: it would be great if these buttons changed states at the same time... the slight delay between one going disabled and the other being disabled feels like a weird cascading effect. I would love for them to happen at the same time.

CleanShot.2025-04-01.at.10.13.16.mp4

@shawnborton
Copy link
Contributor

Also, did we break creating an expense in the selfDM? When I try to send an expense to myself, I don't see any kind of message or preview:

CleanShot 2025-04-01 at 10 46 19@2x

However it does show up on the Reports page, so I know it's being created:
CleanShot 2025-04-01 at 10 47 02@2x

@allgandalf
Copy link
Contributor

Also, did we break creating an expense in the selfDM? When I try to send an expense to myself, I don't see any kind of message or preview:

@shawnborton it's the same bug as described here for split expenses

@shawnborton
Copy link
Contributor

Got it - I assume we'll address in a follow up?

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

@luacmartins all yours

@mountiny mountiny merged commit 763308c into Expensify:main Apr 1, 2025
16 checks passed
Copy link
Contributor

github-actions bot commented Apr 1, 2025

🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.22-0 🚀

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

@vincdargento
Copy link

@Guccio163 Testers are not being able to open the expense details by clicking on the expense preview. Is this intended or known? Or should we create a new issue about this?

Bug6789008_1743521688232.Recording__5315.mp4

@trjExpensify
Copy link
Contributor

@Guccio163 Testers are not being able to open the expense details by clicking on the expense preview. Is this intended or known? Or should we create a new issue about this?

It's known, coming in a follow-up. Here's a condensed list of things we're aware of and coming in a follow-up.

Copy link
Contributor

github-actions bot commented Apr 3, 2025

🚀 Deployed to production by https://github.com/grgia in version: 9.1.22-10 🚀

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

@hoangzinh
Copy link
Contributor

Hi @Guccio163 @allgandalf @luacmartins @mountiny, I can't access the Design doc—could you help confirm if the format of reportName in the new report preview is {report:type} {report:reportID}? I want to double-check since the DEFAULT_REPORT_NAME_PATTERN is {report:type} {report:startdate} (For example Expense Report 2025-04-04)?

Screenshot 2025-04-04 at 23 19 06

@luacmartins
Copy link
Contributor

@hoangzinh I shared the doc with you. I don't think we have that detail in the doc though. AFAIK the report name should follow the formula stored in policy.fieldList.text_title.defaultValue so {report:type} {report:startdate}

@hoangzinh
Copy link
Contributor

Thank you @luacmartins

@jnowakow jnowakow mentioned this pull request Apr 7, 2025
50 tasks
data={transactions.slice(0, 11)}
ref={carouselRef}
nestedScrollEnabled
scrollEnabled={transactions.length > 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

Having scrollEnabled false when transactions.length <= 1 led to this issue:

because having scrollEnabled false was capturing touch on the ReportPreview, which being false means it would block chat vertical scrolling.

We fixed the issue by removing the scrollEnabled (making it true by default), and instead added bounces={false} to deal with a iOS: Native specific rubber band effect of scrollEnabled being always true.

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.