[HOLD] Feat: Update how GBR is determined for IOU/expense reports#29778
[HOLD] Feat: Update how GBR is determined for IOU/expense reports#29778puneetlath merged 15 commits intoExpensify:mainfrom
Conversation
| const defaultSubscriptSize = optionItem.isExpenseRequest ? CONST.AVATAR_SIZE.SMALL_NORMAL : CONST.AVATAR_SIZE.DEFAULT; | ||
| const shouldShowGreenDotIndicator = | ||
| !hasBrickError && (optionItem.isUnreadWithMention || optionItem.isWaitingForTaskCompleteFromAssignee || ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem)); | ||
| const shouldShowGreenDotIndicator = !hasBrickError && (optionItem.isUnreadWithMention || optionItem.isWaitingForTaskCompleteFromAssignee || ReportUtils.shouldShowGBR(optionItem)); |
There was a problem hiding this comment.
Maybe it would be cleaner if we move isUnreadWithMention and isWaitingForTaskCompleteFromAssignee into the shouldShowGBR function. So all the logic of when to show GBR is in there.
tests/unit/SidebarOrderTest.js
Outdated
| expect(screen.queryAllByTestId('Pencil Icon')).toHaveLength(1); | ||
| expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two'); | ||
| expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two owes $100.00'); | ||
| expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two paid $100.00'); |
There was a problem hiding this comment.
Why does this change from owes to paid if all we're doing in this PR is determining whether or not the GBR should be displayed?
There was a problem hiding this comment.
I was thinking about the same thing, but tests were failing, because they were receiving this
There was a problem hiding this comment.
Probably more places where “ hasOutstandingIOU” was doing something
Cc: @puneetlath
There was a problem hiding this comment.
Yeah, I assumed tests failing meant something probably broke in the logic. 😅
Will wait for input from @puneetlath.
There was a problem hiding this comment.
@akinwale updated, changed to previous, hasOutstandingIOU was needed for a correct behaviour
There was a problem hiding this comment.
It looks like this change is no longer in the code? I didn't see it when reviewing.
src/libs/SidebarUtils.js
Outdated
| if (report.isPinned) { | ||
| pinnedReports.push(report); | ||
| } else if (ReportUtils.isWaitingForIOUActionFromCurrentUser(report)) { | ||
| } else if (ReportUtils.shouldShowGBR(report)) { |
There was a problem hiding this comment.
Instead of having a separate section for outstandingIOUReports. Can we just include this in the pinned reports group?
There was a problem hiding this comment.
This will cause multiple changes in tests, but sure, will do that
There was a problem hiding this comment.
If you prefer to handle it in a separate PR that is also fine.
There was a problem hiding this comment.
Does it make sense to have it sorted together?
I mean we always want to have pinned and just after green dots
There was a problem hiding this comment.
I think we'd just do if (report.isPinned || ReportUtils.shouldShowGBR(report)) pinnedReports.push(report);
There was a problem hiding this comment.
But what if green dot report will be before the pinned report, is it a correct behavior?
There was a problem hiding this comment.
Yep that's fine. We want them to be treated the same from an ordering perspective.
There was a problem hiding this comment.
Yep that's fine. We want them to be treated the same from an ordering perspective.
There was a problem hiding this comment.
Updated and updated few tests as it doesnt sort IOU reports and pinned and IOU reports have the same order priority
|
@waterim are you sure this is working in #focus mode? I tried testing it with an account that had |
Will test it once again, was working, but maybe was testing in a wrong way |
|
@puneetlath Fixed the issue and resolved conflicts! |
| return true; | ||
| } | ||
|
|
||
| // Money request waiting for current user to add their credit bank account |
There was a problem hiding this comment.
@waterim actually, we've decided to treat this condition like the others. If a report is waiting on bank account, we will add the hasOutstandingChildRequest to the parent for the submitter and show the green dot on the parent. So let's remove this condition.
There was a problem hiding this comment.
@waterim I think we should remove this whole block:
// Money request waiting for current user to add their credit bank account
// hasOutstandingIOU will be false if the user paid, but isWaitingOnBankAccount will be true if user don't have a wallet or bank account setup
if (!report.hasOutstandingIOU && report.isWaitingOnBankAccount && report.ownerAccountID === currentUserAccountID) {
return true;
}
|
@puneetlath Resolved conflicts once again, second time for the last 3 hours :D |
|
@puneetlath no conflicts, please try to refresh the page |
Reviewer Checklist
Screenshots/Videos |
| return true; | ||
| } | ||
|
|
||
| // Money request waiting for current user to add their credit bank account |
There was a problem hiding this comment.
@waterim I think we should remove this whole block:
// Money request waiting for current user to add their credit bank account
// hasOutstandingIOU will be false if the user paid, but isWaitingOnBankAccount will be true if user don't have a wallet or bank account setup
if (!report.hasOutstandingIOU && report.isWaitingOnBankAccount && report.ownerAccountID === currentUserAccountID) {
return true;
}
| * Determines if a report has an IOU that is waiting for an action from the current user (either Pay or Add a credit bank account) | ||
| * Determines if a report should show a GBR (green dot) in the LHN. This can happen when the report: | ||
| - is unread and the user was mentioned in one of the unread comments | ||
| - is for an outstanding task waiting on the user |
There was a problem hiding this comment.
I don't see the task case covered in the function. Shouldn't it be?
| const archivedReports: Report[] = []; | ||
| reportsToDisplay.forEach((report) => { | ||
| if (report.isPinned) { | ||
| if (report.isPinned ?? ReportUtils.shouldShowGBR(report)) { |
|
@waterim I pushed some commits to try to get it merged today. I hope you don't mind! |
|
@puneetlath ah, sure, no problem, sorry for a late answer, thats a Halloween night and was not near to computer during the evening |
|
All good! We got it across the finish line 🙌🏾 |






Details
This PR is to add tests to IOUTests.js file for submitReport function
Fixed Issues
$ #29595
Tests
N/A
Offline tests
Same as tests
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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.Behaviour is the same for all platforms, attaching screenshots for focused and most recent for IOU green dot
Web
Most recent:
Focus: