[No QA] [Better Expense Report View] Add TransactionPreview component#57614
Conversation
6405358 to
9c8fcba
Compare
|
Let us know when this one is ready for a design review, and I'll run a test build for us. |
Kicu
left a comment
There was a problem hiding this comment.
Dropped you a few more comments, please take a look.
Otherwise the UI itself and story looks really nice 👍
|
Let me know if you have any screenshots to review :) thanks! |
|
I've fixed things you mentioned.
In previous commits in this PR it was possible, but it was because each transaction, action, etc. property was passed separately as a component prop, which resulted in too many props on that component. However, there is an addon called addon-deep-controls which allows a control for every object property in Storybook UI. It would make it possible to change each property separately, so that's one way - I can add this dependency and adapt my story to it - shouldn't take long. But if we do not want additional dev dependency, you can modify |
|
Sounds good, thanks for confirming! I say let's get this into final review then so we can keep marching along. |
allgandalf
left a comment
There was a problem hiding this comment.
code LGTM! , @JakubKorytko can you mark this one as [No QA] since Qa won't be able to test it
|
Marked as [No QA], thank you. |
allgandalf
left a comment
There was a problem hiding this comment.
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 Issuessection 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
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - 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 verified the steps for local testing are in the
- 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 that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
- I verified tests pass on all platforms & I tested again on:
- Android: Native
- Android: mWeb Chrome
- iOS: Native
- iOS: mWeb 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.
toggleReportand notonIconClick). - 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 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
- 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.
- 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 usingAvatarhave 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.ts 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
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - 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(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
Avataris modified, I verified thatAvataris 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
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
- If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
Screenshots/Videos
Android: Native
Screen.Recording.2025-03-14.at.5.02.27.PM.mov
Android: mWeb Chrome
Screen.Recording.2025-03-14.at.5.11.51.PM.mov
iOS: Native
Screen.Recording.2025-03-14.at.4.57.30.PM.mov
iOS: mWeb Safari
Screen.Recording.2025-03-14.at.4.58.14.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2025-03-14.at.4.55.34.PM.mov
MacOS: Desktop
Screen.Recording.2025-03-14.at.5.08.06.PM.mov
| // NOTE: this part of code is needed here if we want to replace MoneyRequestPreview with TransactionPreview | ||
| // const renderCondition = lodashIsEmpty(iouReport) && !(isSplitBillAction || isTrackExpenseAction); | ||
| // return renderCondition ? null : ( |
There was a problem hiding this comment.
Since we have the tableReportView beta, could we just use that now and render the new component if user is on that beta?
There was a problem hiding this comment.
Maybe to keep the PR cleaner, let's not modify the app code in this PR so that it only adds to storybook. We can use them in the code later, when other PR's (like the carousel) are ready
| /** The active IOUReport, used for Onyx subscription */ | ||
| // The iouReportID is used inside withOnyx HOC | ||
| // eslint-disable-next-line react/no-unused-prop-types | ||
| iouReportID: string | undefined; |
There was a problem hiding this comment.
We dont use withOnyx in the component AND I think this should be always same as the reportID, right? Or did you see case when the reportID and iouReportID in this prop is not same?
There was a problem hiding this comment.
I’ve corrected the comment.
I think there is no case when reportID is a different number than iouReportID. However if the report is not IOU then reportID is a number and iouReportID is undefined.
It is a logic that was implemented in MoneyRequestPreview and moved to the new component and I think it is okay to have ID of IOU only if the report is IOU, but I can change this if you want, let me know what you think.
|
@mountiny I've covered every returned value in tests, fixed code according to your comments and also added my own comments, please check if its okay now. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.15-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.1.15-9 🚀
|
| const fromID = chooseIDBasedOnAmount(amount, managerID, ownerAccountID); | ||
| const toID = chooseIDBasedOnAmount(amount, ownerAccountID, managerID); | ||
|
|
||
| return reportOrID && isIOUReport(reportOrID) |
There was a problem hiding this comment.
We haven't considered the case where the IOU report is not available yet upon logging in and we haven't opened that report. Thus caused this bug #59688
| isPreviewHeaderTextComplete = true; | ||
| } | ||
|
|
||
| if (shouldShowRBR && transaction) { |
There was a problem hiding this comment.
With the new table report view, the RBR is shown below the header text, so now we don't need to hide the preview header text when we have a RBR. If we do hide it, as this implemented, the expense status is also hidden (Bug: #60793).
| <View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.FROM)]}> | ||
| <UserInfoCell | ||
| participant={item.to} | ||
| accountID={item.to.accountID} |
There was a problem hiding this comment.
item.to can be undefined when sending an invoice to new user. It's better if we keep the previous optional chaining here
More details: #61310 (comment)
|
|
||
| // When there are no settled transactions in duplicates, show the "Keep this one" button | ||
| const shouldShowKeepButton = areThereDuplicates; | ||
| const shouldShowSplitShare = isBillSplit && !!requestAmount && requestAmount > 0; |
| fill={theme.icon} | ||
| /> | ||
| )} | ||
| <View style={[styles.flex1, styles.mw50]}> |
There was a problem hiding this comment.
2 View with max width 50% and also an arrow will cause an overflow issue when user names are too long and occupy 50% of the width. Ref issue - #67891
| // Clear the draft before selecting a different expense to prevent merging fields from the previous expense | ||
| // (e.g., category, tag, tax) that may be not enabled/available in the new expense's policy. | ||
| abandonReviewDuplicateTransactions(); | ||
| const comparisonResult = compareDuplicateTransactionFields(reviewingTransactionID, transaction?.reportID, transaction?.transactionID ?? reviewingTransactionID); | ||
| setReviewDuplicatesKey({...comparisonResult.keep, duplicates, transactionID: transaction?.transactionID, reportID: transaction?.reportID}); |
There was a problem hiding this comment.
These lines created a race condition where wrong values were set due to quick updates to same onyx values. More details - #79179



Explanation of Change
This is a visual implementation of the replacement for MoneyRequestPreview in Storybook - TransactionPreview.
For now, the MoneyRequestPreview still exists and is being used, so it can't be replaced, the component just lives in the story so it can be easily replaced later.
I'm aware that this component will be inside Carousel, but for the recordings I replaced MoneyRequestPreview locally with this one to get a better view of how these components render in the real environment.
Fixed Issues
$ #57506
PROPOSAL: N/A
Tests
OR
MoneyRequestPreviewrendering in thesrc/components/ReportActionItem/MoneyRequestAction.tsxcomponent withTransactionPreview.returnin the above component with commented code on line 117.Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android-Native.mov
Android: mWeb Chrome
Android-Web.mov
iOS: Native
iOS-Native.mov
iOS: mWeb Safari
iOS-Web.mov
MacOS: Chrome / Safari
Web.mov
Storybook.mov
MacOS: Desktop
Desktop.mov