Repository navigation
Move RBR to workspace chats instead of transaction threads - #51893
Conversation
| // - Belong to the same workspace | ||
| // And if any have a violation, then it should have a RBR | ||
| const allReports = Object.values(ReportConnection.getAllReports() ?? {}); | ||
| const potentialReports = allReports.filter((r: Report) => r?.ownerAccountID === currentUserAccountID && r?.stateNum <= 1 && r?.policyID === report.policyID); |
There was a problem hiding this comment.
error must be for these lines
| }); | ||
| expect(reason).toBe('debug.reasonVisibleInLHN.pinnedByUser'); | ||
| }); | ||
| it('returns correct reason when report has IOU violations', async () => { |
There was a problem hiding this comment.
Deleted this since it seems to me it's testing the same thing as this other test
There was a problem hiding this comment.
What's the harm in leaving it? That sounds better if it's possible for there to be a case that this catches that the other test doesn't
There was a problem hiding this comment.
Why have 2 tests that do the same? It's confusing, useless and a waste of time to have to update it now (and in the future whenever this changes)
There was a problem hiding this comment.
Cause I got the impression that we think they're identical, but not 100% sure. If that's the case, I think it's better to leave it, but NAB
|
@ 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] |
|
Oh I also need to update a regression test: https://expensify.slack.com/archives/C9YU7BX5M/p1730833945360329 |
|
@iwiznia Should we review or wait? I am a little confused |
|
Review! What was confusing? |
|
@iwiznia You mentioned something about regression tests so I wasn't sure if you wanted to add more tests to the PR |
Yes, if you follow the link, we have a plan to update the regression tests when this is merged, but that update is outside of this PR code. |
cead22
left a comment
There was a problem hiding this comment.
Thanks for taking this on! I think one of the most important parts of this PR should be to update the regression tests we have for violations to make sure the steps that used to check for RBRs on the transaction threads are updated to check the workspace chat.
That way we can have Applause run the full suite of violation tests as part of this PR and be confident we're not going to push bugs
| }); | ||
| expect(reason).toBe('debug.reasonVisibleInLHN.pinnedByUser'); | ||
| }); | ||
| it('returns correct reason when report has IOU violations', async () => { |
There was a problem hiding this comment.
What's the harm in leaving it? That sounds better if it's possible for there to be a case that this catches that the other test doesn't
| data?: TransactionViolationData; | ||
|
|
||
| /** Indicates if this violation should be shown in review */ | ||
| showInReview?: boolean; |
There was a problem hiding this comment.
Does this need to be optional?
There was a problem hiding this comment.
Yes, because I am not sending it from PHP when it is not true
There was a problem hiding this comment.
| showInReview?: boolean; | |
| showInReview: boolean | undefined; |
This should be required to be set (and still allow for undefined). This is needed so we create the correct optimistic data. Not doing so led to a regression #54510
However, now we need to know which violations has showInReview=true. Can you please provide a list?
There was a problem hiding this comment.
Why would this need to be set for optimistic actions to work? 😕
However, now we need to know which violations has showInReview=true. Can you please provide a list?
I don't think there's a list, there's a bunch of logic controlling this property's value.
There was a problem hiding this comment.
Why would this need to be set for optimistic actions to work?
If we don't then expenses created offline that violate policy rules won't have the red dot set on their previews. This is due to this logic
showInReview=true
There was a problem hiding this comment.
Ah ok, so let's add that property to the optimistic actions (assuming the property will be removed when the data from the server is returned), but no need to mark this prop as required
There was a problem hiding this comment.
The problem with not making this required is that the bug could resurface (one could simply forget to add the field). Do you think we shouldn't optimize for this case?
There was a problem hiding this comment.
Do you think it actually prevents bugs? Allowing undefined gives the same signal to code authors as allowing it to not be passed, no?
There was a problem hiding this comment.
I see your point. Forcing the field to be set can reduce the occurrence of such bugs as you will get a chance to put in the correct value but it won't 100% prevent the bug.
We will keep the types untouched.
| (violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.WARNING, | ||
| ); | ||
| function hasWarningTypeViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, showInReview?: boolean | null): boolean { | ||
| const warningTypeViolations = |
There was a problem hiding this comment.
NAB but break this down to make it more readable
There was a problem hiding this comment.
Like how? I had it formatted more readable but then the styler changed it to this
There was a problem hiding this comment.
Putting transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID] in a variable
There was a problem hiding this comment.
Did that, not sure if it makes it any better though 🤷
| const warningTypeViolations = transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.filter( | ||
| (violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.WARNING, | ||
| ); | ||
| function hasWarningTypeViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, showInReview?: boolean | null): boolean { |
There was a problem hiding this comment.
Can we make the last param mandatory?
| * Checks to see if a report contains a violation of type `warning` | ||
| */ | ||
| function hasWarningTypeViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>): boolean { | ||
| function hasWarningTypeViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean { |
There was a problem hiding this comment.
Can we make the last param mandatory?
| * Checks if any violations for the provided transaction are of type 'violation' | ||
| */ | ||
| function hasViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolations>): boolean { | ||
| function hasViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolations>, showInReview?: boolean): boolean { |
There was a problem hiding this comment.
Can we make the last param mandatory?
| */ | ||
| function hasNoticeTypeViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolation[]>): boolean { | ||
| return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.NOTICE); | ||
| function hasNoticeTypeViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, showInReview?: boolean): boolean { |
There was a problem hiding this comment.
Can we make the last param mandatory?
| * Checks to see if a report contains a violation | ||
| */ | ||
| function hasViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>): boolean { | ||
| function hasViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean { |
There was a problem hiding this comment.
Can we make the last param mandatory?
There was a problem hiding this comment.
In the places we are calling this that I did not update, we do not care about the state of this variable, so no.
| // - Owned by the same user | ||
| // - Are either open or submitted | ||
| // - Belong to the same workspace | ||
| // And if any have a violation, then it should have a RBR |
There was a problem hiding this comment.
I see this condition was deleted if (isSettled(IOUReportID) || isReportApproved(IOUReportID?.toString())) {, but should we be checking for settled/approved reports, and only show RBR on workspace chats if there's an expense report on the same policy of the workspace chat that isn't approved or settled?
There was a problem hiding this comment.
That's done with (r.stateNum ?? 0) <= 1 below
|
I will wait for the ^ comments to be addressed before continuing the review |
Co-authored-by: Carlos Alvarez <carlos@expensify.com>
|
🎯 @allgandalf, thanks for reviewing and testing this PR! 🎉 An E/App issue has been created to issue payment here: #52341. |
That phrase is not there anymore, I think you were looking at the outdated description? |
i guess my GH's live update didn't work this time 🤣 |
|
@iwiznia @cead22 We removed the App/src/libs/WorkspacesSettingsUtils.ts Line 70 in 861d7e5 |
|
🚀 Deployed to staging by https://github.com/cead22 in version: 9.0.61-0 🚀
|
|
Damn, so someone must've added a usage in the meantime |
Yes |
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.0.61-3 🚀
|
| function hasViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolations>, showInReview?: boolean): boolean { | ||
| return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some( | ||
| (violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.VIOLATION, | ||
| (violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.VIOLATION && (showInReview === undefined || showInReview === (violation.showInReview ?? false)), |
There was a problem hiding this comment.
This logic is confusing. If showInReview is false and violation.showInReview is unset (not sent by BE). Then we will end up showing this in review? (false === false)

Held on https://github.com/Expensify/Web-Expensify/pull/44293Explanation of Change
Fixed Issues
https://github.com/Expensify/Expensify/issues/433103
Tests
Offline tests
No
QA Steps
Same as tests
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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop