Add markAsCash button with wired up action for dismissing the rter violation#41835
Conversation
| const hasFooterRendered = useRef(false); | ||
| const lastVisibleActionCreatedRef = useRef(report.lastVisibleActionCreated); | ||
| const lastReadTimeRef = useRef(report.lastReadTime); | ||
| // Single MoneyRequest |
There was a problem hiding this comment.
It is showing as a change, because ola removed it in her PR and this branch was based on it
| width={variables.iconSizeExtraSmall} | ||
| fill={theme.textSupporting} | ||
| /> | ||
| <Text style={[styles.textLabel, styles.colorMuted, styles.ml1, styles.amountSplitPadding]}>{translate('iou.receiptScanInProgress')}</Text> |
There was a problem hiding this comment.
NAB: We can consider creating a new style for it.
There was a problem hiding this comment.
I would check if any other use cases appear in the first place and apply it separately, but yeah that's probably a good idea
| const getPendingType = () => { | ||
| if (TransactionUtils.isExpensifyCardTransaction(transaction) && TransactionUtils.isPending(transaction)) { | ||
| return {pendingType: 'PENDING', pendingTitle: translate('iou.pending'), pendingDescription: translate('iou.transactionPendingText')}; | ||
| } | ||
| if (isScanning) { | ||
| return {pendingType: 'SCANNING', pendingTitle: ReceiptScan, pendingDescription: translate('iou.receiptScanInProgressDescription')}; | ||
| } | ||
| if (TransactionUtils.hasPendingRTERViolation(TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '', transactionViolations))) { | ||
| return {pendingType: 'RTER', pendingTitle: Expensicons.Hourglass, pendingDescription: translate('iou.pendingMatchWithCreditCardDescription')}; | ||
| } | ||
| return {}; | ||
| }; |
There was a problem hiding this comment.
To consider: adding useCallback.
There was a problem hiding this comment.
- it's based on the transaction, which is one of the key elements that change in this components props, so probably there wouldn't be any major benefits coming from this change
- probably useMemo would be more suitable, but as I stated, there aren't any major benefits and since there aren't any issues either we should avoid it as stated in the docs
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`, | ||
| value: { | ||
| [optimisticReportAction.reportActionID]: null, |
There was a problem hiding this comment.
Just want to make sure: which offline pattern do we follow here? Is it B (Optimistic WITH Feedback Pattern)?
There was a problem hiding this comment.
it's from the other branch that has already been merged, but @yuwenmemon probably has more context regarding this action
|
@BrtqKr Merge main to simplify the diff a bit! |
|
@BrtqKr Quick bump on this! I believe all pre-requisite PRs have been merged |
|
@dubielzyk-expensify @c3024 @grgia One of you needs to 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] |
dubielzyk-expensify
left a comment
There was a problem hiding this comment.
Looks good to me from a visual perspective. cc @Expensify/design for visibility
|
Yup, exactly! |
|
I could have sworn on mobile, we show the green button above the status - does that sound correct? |
|
@shawnborton in the design doc, the button is below the status, like it is here. 🤷♂️ |
Hmm that seems weird to me. I would expect it to be in the transaction thread, not the report thread. (Like if you change the category of an expense, that system message shows up in the expense thread.) I would also expect it to have the avatar/name of the person who marked it as cash. @JmillsExpensify @shawnborton does that sound right to you?
I think @JmillsExpensify would know better, but I feel like the preview should be showing an RBR/error message instead of "Unknown Merchant"... Unless of course someone set the merchant to |
I agree it should be in the transaction thread. As for the avatar, I think it follows the same logic as when the same user sends multiple messages consecutively where we skip the avatar if you send a bunch of messages in a row. |
Ah that makes sense. So since this is (wrongly) showing up in the report thread, it's piggy-backing off of the request message. Once we get it in the expense thread like it's supposed to be, that issue should go away. 🤞 |
|
Hmmm yeah @BrtqKr That seems to be stemming from some sort of optimistic action we're adding to the parent report because once you sign in and out, those messages disappear: Kapture.2024-05-20.at.11.53.15.mp4 |
|
@yuwenmemon isn't it because we're using a random id for the messaging optimistic update? Maybe Onyx isn't able to relate the success id and the random one generated in the action and we should be removing it in the Screen.Recording.2024-05-21.at.12.15.50.mov |
| text={translate('iou.markAsCash')} | ||
| style={[styles.p0]} | ||
| onPress={() => { | ||
| TransactionActions.markAsCash(transaction?.transactionID ?? '', transaction?.reportID ?? ''); |
There was a problem hiding this comment.
@BrtqKr I think this is the source of your issue. We should be using the transactionThreadID here, not the report ID of the transaction.
|
@BrtqKr I don't think it's that, no. I commented on the PR on the line that I believe to be the culprit. Essentially we're passing the transaction's reportID to |
|
Quickly confirming that yes, this should appear in the transaction thread. |
|
@c3024 Can you prioritize your review of this PR ASAP? |
| text={translate('iou.markAsCash')} | ||
| style={[styles.p0]} | ||
| onPress={() => { | ||
| TransactionActions.markAsCash(transaction?.transactionID ?? '', transactionThreadReportID ?? ''); |
There was a problem hiding this comment.
| TransactionActions.markAsCash(transaction?.transactionID ?? '', transactionThreadReportID ?? ''); | |
| TransactionActions.markAsCash(transaction?.transactionID ?? '', report?.reportID ?? ''); |
| text={translate('iou.markAsCash')} | ||
| style={[styles.w100, styles.pr0]} | ||
| onPress={() => { | ||
| TransactionActions.markAsCash(transaction?.transactionID ?? '', transaction?.reportID ?? ''); |
There was a problem hiding this comment.
| TransactionActions.markAsCash(transaction?.transactionID ?? '', transaction?.reportID ?? ''); | |
| TransactionActions.markAsCash(transaction?.transactionID ?? '', report?.reportID ?? ''); |
I think it is better to extract this to a local function because it is used twice and in the last commit only one instance was updated.
| } | ||
| if (TransactionUtils.hasPendingRTERViolation(TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '', transactionViolations))) { | ||
| return {title: getStatusIcon(Expensicons.Hourglass), description: translate('iou.pendingMatchWithCreditCardDescription'), shouldShowBorderBottom: true}; | ||
| return { |
There was a problem hiding this comment.
This should be moved above the isScanning message. That is how it is in oneTransactionReports. When there is an RTER violation that message should be shown instead of the 'being scanned' message.
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / SafarimarkAsCashChrome.mp4MacOS: DesktopmarkAsCashDesktop.mp4 |
|
NAB: Also, |
|
✋ 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/yuwenmemon in version: 1.4.76-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.4.76-7 🚀
|












Details
Fixed Issues
$ #39541
PROPOSAL:
Tests
transactionIdOffline tests
As the standard ones.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-05-10.at.11.51.40.mov
Screen.Recording.2024-05-10.at.13.49.11.mov
MacOS: Desktop
Screen.Recording.2024-05-10.at.12.04.43.mov