Skip to content

[Better Expense Reports] Add MoneyRequestReportView #58360

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

Merged

Conversation

Kicu
Copy link
Member

@Kicu Kicu commented Mar 13, 2025

This PR adds new view called MoneyRequestReportView which will display a grouped list of report transactions at top and chat items below.

It implements parts of: https://docs.google.com/document/d/12RD9MO-CXFwcehkqLdWvx0__mK8Ou_0cMBYG5BVNULc/edit?tab=t.0#bookmark=id.vbs1mmt4xhw4

Explanation of Change

  • Introduces cleaned up MoneyRequestReportView, which displays list of transactions and chat items
    • transaction list consists of all transactions filtered by reportID
    • the chat list uses the same rendering logic as normal ReportScreen but we filter out CREATED and IOU actions because CREATED is not relevant to this view and IOU is the transaction list ☝️
  • reuses a lot of logic from: ReportScreen, ReportActionsView and ReportActionsList
  • currently new view is only displayed in Search context (Search LHN)
  • uses tableReportView beta to redirect Search report items to the new view - without this beta the user cannot access new screen
  • abstracts away SearchTableHeader into component called SortableTableHeader to use the same header both in Search table and MoneyRequestReport table

NOTE: this PR is already quite big so I wanted to divide it into smaller parts to allow for reasonable review.

These don't yet work and will be done in separated PR

  • rest of report actions list functionalities like divider line etc.
  • sorting transaction list (at the top of screen)
  • chat message count on transaction row

Fixed Issues

$ #57508
PROPOSAL:

Tests

Important: in order to test change function canUseTableReportView to return true, or have BETA tableReportView set

  • open Search, go to Expense Reports
  • click on any report
  • verify you see the new view, and not report in RHP
  • verify that transactions are visible, note in this view the user always starts at the top of chat messages
  • verify that composer works
  • verify that report actions are correctly displayed
  • Please note that there are parts of this not done yet, described above in the description

Offline 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 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: mWeb Chrome
iOS: Native
rec-report-ios.mp4
iOS: mWeb Safari
rec-report-ios-mweb.mp4
MacOS: Chrome / Safari
rec-report-web.mp4
MacOS: Desktop

@Kicu Kicu force-pushed the kicu/57508-add-report-view branch from 6506e89 to 8f630ba Compare March 13, 2025 13:26
@luacmartins luacmartins self-requested a review March 13, 2025 15:23
@mountiny mountiny self-requested a review March 13, 2025 15:28
@Kicu Kicu force-pushed the kicu/57508-add-report-view branch 2 times, most recently from ceca442 to 5ed0a75 Compare March 14, 2025 13:35
@Kicu Kicu force-pushed the kicu/57508-add-report-view branch 2 times, most recently from 33c9d0e to 35d7b65 Compare March 17, 2025 14:10
const {isOffline} = useNetwork();

const {shouldUseNarrowLayout} = useResponsiveLayout();
const contentListHeight = useRef(0);
Copy link
Member Author

@Kicu Kicu Mar 17, 2025

Choose a reason for hiding this comment

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

Please note this is a cleanup.
I have noticed that this ref was not used anywhere. It was updated in onContentSizeChange and never used after that nor passed down.

Copy link
Contributor

Choose a reason for hiding this comment

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

Kinda feel like ideally we would do that in a separate PR in case there is any regression with the hook

@Kicu Kicu force-pushed the kicu/57508-add-report-view branch from 35d7b65 to dd279c5 Compare March 17, 2025 14:21
@Kicu Kicu changed the title [WIP] Add MoneyRequestReportView Add MoneyRequestReportView Mar 17, 2025
@Kicu
Copy link
Member Author

Kicu commented Mar 17, 2025

I have some problems building android hybrid app. Need to do a clean install, so I will upload android videos tomorrow.

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

melvin-bot bot commented Mar 17, 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]

@Kicu
Copy link
Member Author

Kicu commented Mar 17, 2025

CC @mountiny @luacmartins ready to review, please take a look at the description.

@shawnborton
Copy link
Contributor

Do you want the @Expensify/design to do a thorough review of this or not yet?

@mountiny mountiny changed the title Add MoneyRequestReportView [Better Expense Reports] Add MoneyRequestReportView Mar 17, 2025
@luacmartins
Copy link
Contributor

@DylanDylann let's prioritize reviewing this PR when you're online

@luacmartins
Copy link
Contributor

Do you want the @Expensify/design to do a thorough review of this or not yet?

@shawnborton I think we can save design review for later when we have more of the functionality in place.

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

Left a few comments. Additionally, found some minor issues:

  1. Table header is not aligned with table data
    Screenshot 2025-03-17 at 1 26 20 PM

  2. Date from previous year is cut off
    Screenshot 2025-03-17 at 1 26 25 PM

  3. Incorrect cursor shown on hover

Screen.Recording.2025-03-17.at.1.26.44.PM.mov
Screen.Recording.2025-03-17.at.1.27.08.PM.mov
  1. Violations don't have padding on small screens
    Screenshot 2025-03-17 at 1 30 36 PM

  2. Items without violations have bigger height than needed
    Screenshot 2025-03-17 at 1 31 17 PM

shouldShow: (data: OnyxTypes.SearchResults['data'], metadata: OnyxTypes.SearchResults['search']) => boolean;
};

const shouldShowColumnConfig: Record<SearchColumnType, ShouldShowSearchColumnFn> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we move this out of SearchColumnConfig?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question?

Copy link
Member Author

Choose a reason for hiding this comment

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

Short answer: code decoupling + TS types

In search table some of shouldShow functions needed extra search data to make the decision whether to display a column. These function had signatures like this:

(data: OnyxTypes.SearchResults['data'], metadata: OnyxTypes.SearchResults['search']) => boolean

I needed to create a clean reusable SortableTableHeader component. Inside this component I need a shouldShow function, but I don't want to make its arguments depend on search data/metadata. It would be hard to use it for ReportsView then.
Because of that, inside SearchTableHeader I had to split types that are connected to search data (shouldShow) from columnsConfig. That means columnsConfig is now only names of columns + translation keys - generic types.
I'm quite happy with this solution.
(If you remember @luacmartins we had similar problems with chat name generation, where it was tightly coupled to reports data in Onyx and hard to reuse in Search - I want to avoid that here)

const currentAction = reportActions.at(actionIndex);
const nextAction = findNextAction(reportActions, actionIndex);

// Todo first should have avatar - verify that this works with long chats
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, are we doing this in a follow up?

Suggested change
// Todo first should have avatar - verify that this works with long chats
// Todo first should have avatar - verify that this works with long chats

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 lets link issues in which we would handle this in each TODO

Copy link
Member Author

@Kicu Kicu Mar 18, 2025

Choose a reason for hiding this comment

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

let's combine these two, because both touch the same part of code - displaying avatars on grouped comments.
Since the existing solution is working specifically only on InvertedList I had to re-implement it for non-inverted lists.

Both TODO comments are leftovers after my change so they should be fixed together.

Copy link
Member Author

Choose a reason for hiding this comment

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

issue created: #58625

@Kicu
Copy link
Member Author

Kicu commented Mar 19, 2025

Yes correct 👍 the reportActions are reversed but the List is not.
In this view you "start at the top", so if there are just 1-2 comments then they should be aligned to the top of the whole view, not to the bottom as currently when looking at chats/expenses.

@melvin-bot melvin-bot bot requested a review from mountiny March 19, 2025 10:26
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.

Thanks! going to merge this so @JakubKorytko and other PRs can base their changes from this more easily today but @luacmartins please feel free to review this PR still

@trjExpensify
Copy link
Contributor

The LHN Expenses is still highlighted when in an individual report view. Is removing that on the follow-up list? (I seem to recall it mentioned somewhere else already).

image

Similarly, is the table footer with the Comments header and report Total amount slated for a follow-up? I see those missing as well. Ref:

image

@mountiny mountiny merged commit e292fa1 into Expensify:main Mar 19, 2025
20 checks passed
@mountiny
Copy link
Contributor

@JakubKorytko Could work those notes into his PR

@JakubKorytko
Copy link
Contributor

Noted, will take a look later, focusing on sorting functionality rn.

@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.

@Kicu
Copy link
Member Author

Kicu commented Mar 19, 2025

I will also work on those. I'm adding comments to the original issue so that we don't forget about anything 👍

Copy link
Contributor

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

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

@deetergp
Copy link
Contributor

I believe that this PR is the cause of this deploy blocker. I have reverted this in main locally and confirmed that the bug goes away.

@trjExpensify
Copy link
Contributor

It's behind a beta 👍

@deetergp
Copy link
Contributor

Noted. We demoted it from being a blocker.

Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.1.16-4 🚀

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

@Kicu Kicu mentioned this pull request Mar 25, 2025
48 tasks
Comment on lines +562 to +563
function findNextAction(reportActions: ReportAction[], actionIndex: number): OnyxEntry<ReportAction> {
for (let i = actionIndex - 1; i > 0; i--) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This loop stops at 1 (i > 0) and does not check the first report action. The condition should have been i >= 0.

Coming from #59948

shouldUseThreadDividerLine={shouldUseThreadDividerLine}
shouldDisplayReplyDivider={visibleReportActions.length > 1}
isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed passing linkedReportActionID here for message highlighting when clicking header to go back to a linkedReportAction, leading to this issue:

lastReportAction={lastReportAction}
/>
) : null}
</View>
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 #60747, missing <PortalHost name="suggestions" /> resulted in a broken suggestion list.

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.