Skip to content

Improve MoneyRequestReportView#58903

Merged
mountiny merged 24 commits intoExpensify:mainfrom
software-mansion-labs:kicu/57508-improve-money-report-view
Mar 31, 2025
Merged

Improve MoneyRequestReportView#58903
mountiny merged 24 commits intoExpensify:mainfrom
software-mansion-labs:kicu/57508-improve-money-report-view

Conversation

@Kicu
Copy link
Contributor

@Kicu Kicu commented Mar 21, 2025

Work in progress

This adds more updates to MoneyRequestReportView.
Also updates existing header that is displayed for single-transaction view to add navigation to it (< >).

Things fixed:

list of required followups

  • automatic scrolling to bottom when user writes a new message

Explanation of Change

Fixed Issues

$ #57508
$ #58851
$ #58854
$ #58813
$ #58857

PROPOSAL:

Tests

  • go to Reports -> Expense Reports and click on any report
  • it should open in the new view with transactions list at the top
  • verify that all the chat messages that should be seen by user are displayed
  • verify that sorting still works
  • verify that clicking on transaction row works and opens RHP with transaction-report
  • verify that totals below transaction list displays correctly

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
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@DylanDylann
Copy link
Contributor

@Kicu could you list out what is done here? Then I can review it first

@Kicu
Copy link
Contributor Author

Kicu commented Mar 25, 2025

@DylanDylann I will list this and make it much better for reviewing in a few hours todaym, once I finalize a few more things 👍

@Kicu Kicu force-pushed the kicu/57508-improve-money-report-view branch from b384ab4 to 22606bc Compare March 25, 2025 15:11
@Kicu
Copy link
Contributor Author

Kicu commented Mar 25, 2025

hey @DylanDylann sorry it took so long, this is quite a complicated view 😅

Here's what I'm expecting to work:

What's expected to NOT work:

  • will not scroll to bottom in every case (I will be working on it in the upcoming days)
  • there is no selection checkboxes - @jnowakow is working on them
  • no "new messages" indicator

You can start reviewing these parts now. I will try to open it tomorrow for review and will ask you before pushing any more changes. Thanks! 🙏

@Kicu
Copy link
Contributor Author

Kicu commented Mar 25, 2025

@Expensify/design feel free to drop any comments with the caveats described here: https://swmansion.slack.com/archives/C07NMDKEFMH/p1742917369637919?thread_ts=1742890386.286389&cid=C07NMDKEFMH

@Kicu
Copy link
Contributor Author

Kicu commented Mar 25, 2025

quick demo:

rec-demo.mp4

@Kicu
Copy link
Contributor Author

Kicu commented Mar 25, 2025

@DylanDylann @mountiny @luacmartins in here I described why I'm rewriting parts of logic related to scrolling etc for anyone that might think it's weird or unnecessary 😅

@github-actions
Copy link
Contributor

🚧 @luacmartins has triggered a test app build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@shawnborton
Copy link
Contributor

Minor comment: maybe 16px of top padding feels a bit better for the report header?
CleanShot 2025-03-25 at 19 01 55@2x

@shawnborton
Copy link
Contributor

If a report has no comments, we don't need the floating "Comments" label here:
CleanShot 2025-03-25 at 19 02 55@2x

@shawnborton
Copy link
Contributor

Let's add 12px of right padding to the totals area, so it aligns with the total above:
CleanShot 2025-03-25 at 19 03 56@2x

@shawnborton
Copy link
Contributor

Let's reduce the padding under the table to 16px so the totals sit slightly closer:
CleanShot 2025-03-25 at 19 04 45@2x

@shawnborton
Copy link
Contributor

If there's only one expense on the report, we don't need the carousel buttons:
CleanShot 2025-03-25 at 19 06 43@2x

@shawnborton
Copy link
Contributor

We want a gap of 8px between all of the sub-totals and totals, right now I think it's just 4px:
CleanShot 2025-03-25 at 19 09 23@2x

@shawnborton
Copy link
Contributor

I don't think this is related to this PR but just noting that some reports aren't displaying merchant or amount in the table:
CleanShot 2025-03-25 at 19 14 25@2x

@Kicu
Copy link
Contributor Author

Kicu commented Mar 31, 2025

@DylanDylann conflicts resolved, I needed to slightly change logic of showing empty state/skeletons.
Fixed 2 small problems that you found.

BUG: In the first time go to MoneyRequestReportView, the transactions doesn't display

I can't reproduce this :/ the only thing I can reproduce is that initially smaller amount of transactions load and then after a second all transactions load which looks bad - but I didn't have the case where no transactions were displayed.

There is small bug we found in related to this which @jnowakow will fix in his PR.
This state can become stale: https://github.com/Expensify/App/pull/58713/files#diff-fdae540f324f25f7a8b7f7c44ebf5eb8681a7cef16b937fd24ef2546618561baR56-R60

But this change will come in a separate PR

@github-actions
Copy link
Contributor

🚧 @mountiny has triggered a test app build. You can view the workflow run here.

mountiny
mountiny previously approved these changes Mar 31, 2025
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.

Big PR, I expect there will be some new things which pop up after QA testing in staging, but great to move this ahead

Comment on lines +123 to +133
// Single transaction report will open in RHP, and we need to find every other report ID for every sibling to `activeTransaction`
// we use this data to display prev/next arrows in RHP for navigating between transactions
const sortedSiblingTransactionReportIDs = sortedData.transactions
.map((transaction) => {
const action = getIOUActionForTransactionID(reportActions, transaction.transactionID);
return action?.childReportID;
})
.filter((reportID): reportID is string => !!reportID);

setActiveTransactionReportIDs(sortedSiblingTransactionReportIDs);

Copy link
Contributor

Choose a reason for hiding this comment

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

Coul dbe nice to cover this logic with unit test

headerStyles={[styles.emptyStateMoneyRequestReport]}
lottieWebViewStyles={styles.emptyStateFolderWebStyles}
headerContentStyles={styles.emptyStateFolderWebStyles}
minModalHeight={380}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add this as a CONST?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could, but I don't think it's that important. This component itself is a specific component dedicated to MoneyRequestReport. Also empty state inside it also uses a specific number as a default:

If I'm to make this a const, I would still keep it inside this file. I don't think is a value that anyone else should read or use. Its a specific height for this specific component

* By default api returns report actions newest-first, and then older ones on subsequent pagination calls.
* If this flag is set to true, api will return oldest first starting from the beginning of report.
*/
useTableReportView?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it now can be set as true always and basically indicates the client version can handle this new view. in BE we check if the user has the beta and only then we return the reversed order


// temporary flag will be removed once ReportScreen supports MoneyRequestReportView - https://github.com/Expensify/App/issues/57509
// Permission will be removed before the end of the project
if (temporaryShouldUseTableReportView && Permissions.canUseTableReportView(allBetas)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

But you do not have to check for the beta anymore, its handled in the BE

@github-actions
Copy link
Contributor

🧪🧪 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/58903-hybrid/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/58903-hybrid/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/58903/NewExpensify.dmg https://58903.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@Kicu
Copy link
Contributor Author

Kicu commented Mar 31, 2025

@mountiny I can add some unit tests and fix the permissions check in ~30mins

@mountiny
Copy link
Contributor

Great, thank you!

@shawnborton
Copy link
Contributor

Excited to get this one merged, looking good on my end 👍

@Kicu Kicu force-pushed the kicu/57508-improve-money-report-view branch from 4eea9f6 to 8d628fe Compare March 31, 2025 14:53
@Kicu
Copy link
Contributor Author

Kicu commented Mar 31, 2025

@mountiny removed the permissions check and added some unit tests for picking reportIDs.
Please note that "mockData" is a work in progress, which we will be editing together with other guys as we build this feature.

It will be used for tests (and stories). So right now the file is a bit messy, but it will be updating it whenever me (or one of the other guys from SWM) will be adding any tests :)

@Kicu Kicu force-pushed the kicu/57508-improve-money-report-view branch from bb9f6a0 to 739e58d Compare March 31, 2025 15:00
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.

Looking great! Left a couple of NAB. Also, this has been reported before, but just wanted to mention it again, the empty receipt background color is still incorrect (NAB for this PR though):

Screenshot 2025-03-31 at 9 14 31 AM

*/

function setActiveTransactionReportIDs(ids: string[]) {
// Cleaning previously saved keys because
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB was there an end to this sentence?

Suggested change
// Cleaning previously saved keys because
// Cleaning previously saved keys because

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 will fix in another PR 😅

Comment on lines 32 to +33
case undefined:
return 'Cash';
return 'iou.cash';
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB do we need this specific case? Can't we just use the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will see if default handles it, but most likely we can make improve it

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!

@mountiny mountiny merged commit 3d60ce6 into Expensify:main Mar 31, 2025
21 checks passed
@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.

@github-actions
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 ✅

@github-actions
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 ✅

shouldDisplaySearchRouter
shouldShowBackButton={shouldUseNarrowLayout}
onBackButtonPress={Navigation.goBack}
linkKey="notFound.noAccess"
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 #60014. This caused an issue where the This chat doesn't exist message was duplicated, since we're setting both subtitleKey and linkKey. We removed linkKey since it's unnecessary in this context.

</View>
)}
<View style={[styles.dFlex, styles.flexRow, listHorizontalPadding, styles.justifyContentBetween, styles.mb2]}>
<Text style={[styles.textLabelSupporting]}>{hasComments ? translate('common.comments') : ''}</Text>
Copy link
Member

@s77rt s77rt Jun 15, 2025

Choose a reason for hiding this comment

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

The comments subheader should have been moved outside the !isEmpty(transactions) condition so that it's displayed for reports with no transactions too.

Coming from #63076


// Single transaction report will open in RHP, and we need to find every other report ID for the rest of transactions
// to display prev/next arrows in RHP for navigating between transactions
const sortedSiblingTransactionReportIDs = getThreadReportIDsForTransactions(reportActions, sortedData.transactions);
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to filter out pending delete transactions to avoid issue of navigating to those transactions.

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.

[Due for payment 2025-04-10] [Better Expense Report View] iOS - Reports - Report view is blank and does not show skeleton when fetching data

10 participants