-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Add red dot to one transaction reports #44810
Conversation
@Pujan92 can you review this one please? Thanks! |
Reviewer Checklist
Screenshots/VideosAndroid: Nativemm1.webmiOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-11.at.14.51.18.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-11.at.14.56.30.mp4MacOS: Chrome / SafariScreen.Recording.2024-07-10.at.19.51.35.movMacOS: Desktop |
src/libs/SidebarUtils.ts
Outdated
const transactionReportActions = ReportActionsUtils.getAllReportActions(report.reportID); | ||
const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, transactionReportActions, undefined); | ||
let doesTransactionThreadReportHasViolations = false; | ||
if (oneTransactionThreadReportID) { | ||
const transactionReport = getReport(oneTransactionThreadReportID); | ||
doesTransactionThreadReportHasViolations = !!transactionReport && OptionsListUtils.shouldShowViolations(transactionReport, betas ?? [], transactionViolations); | ||
} | ||
const hasErrorsOtherThanFailedReceipt = | ||
doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== Localize.translateLocal('iou.error.genericSmartscanFailureMessage')); | ||
doesTransactionThreadReportHasViolations || | ||
doesReportHaveViolations || | ||
Object.values(allReportErrors).some((error) => error?.[0] !== Localize.translateLocal('iou.error.genericSmartscanFailureMessage')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these changes? I don't think we require it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is to make sure the one transaction report is always pinned in LHN as mentioned in comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Thanks!
@@ -278,6 +297,21 @@ function getOptionData({ | |||
result.shouldShowSubscript = ReportUtils.shouldReportShowSubscript(report); | |||
result.pendingAction = report.pendingFields?.addWorkspaceRoom ?? report.pendingFields?.createChat; | |||
result.brickRoadIndicator = hasErrors || hasViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; | |||
const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, ReportActionsUtils.getAllReportActions(report.reportID)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of putting this logic here, how about placing it with the parent report OptionRowLHNData
? I am suggesting this to keep the shouldDisplayViolations
in a single place.
App/src/components/LHNOptionsList/OptionRowLHNData.tsx
Lines 37 to 39 in dd96852
const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction); | |
const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID, ReportActionsUtils.getAllReportActions(reportID));
let shouldDisplayOneTransactionThreadViolation = false;
if (oneTransactionThreadReportID) {
const oneTransactionThreadReport = getReport(oneTransactionThreadReportID);
if (
ReportUtils.shouldDisplayTransactionThreadViolations(
oneTransactionThreadReport,
transactionViolations,
ReportActionsUtils.getAllReportActions(reportID)[oneTransactionThreadReport?.parentReportActionID ?? '-1'],
)
) {
shouldDisplayOneTransactionThreadViolation = true;
}
}
const shouldDisplayViolations = canUseViolations && (ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction) || shouldDisplayOneTransactionThreadViolation);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should let the SizebarUtils
handle the logic to display the RBR in case one transaction report has violations because:
-
We have already handled the logic to pin the one transaction report if it has a violation in
SizebarUtils
. So the logic to display RBR should be placed here for easier management. -
Reduce the complexity of the
OptionRowLHNData
file.
cc @robertjchen What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok 👍
@truph01 We also need to update the test steps bcoz now we are not showing three dots in the header. |
@Pujan92 Sure. I am checking it now |
@Pujan92 Pls help check my responses above. Thanks |
src/libs/actions/Task.ts
Outdated
@@ -1163,6 +1163,7 @@ export { | |||
clearTaskErrors, | |||
canModifyTask, | |||
setNewOptimisticAssignee, | |||
getReport, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to ReportUtils as it fits there more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@truph01 plz update the test steps.
@Pujan92 I updated test steps to remove "Click on three dot" step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but looks like there's a conflict
I resolved the conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
✋ 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/robertjchen in version: 9.0.7-3 🚀
|
🚀 Cherry-picked to staging by https://github.com/thienlnam in version: 9.0.7-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
function getReport(reportID: string): OnyxEntry<Report> { | ||
return ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I don't think we should be exporting getReport anymore. It was previously removed in #43632. They added a test rule to prevent the export, but they got the name wrong.
App/tests/actions/EnforceActionExportRestrictions.ts
Lines 32 to 35 in 7d58aa6
it('does not export getReport', () => { | |
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal | |
expect(ReportUtils.getReportOrDraftReport).toBeUndefined(); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj Thanks. I will note it in the future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bernhardoj.
To contrary, ReportConnection.ts
is created to keep track of all the reports instead of subscribing it from all the components for the performance improvement in #44068. Maybe we can move getReport
there, though it is the same.
Thoughts @robertjchen ?
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.7-8 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.8-6 🚀
|
Details
Fixed Issues
$ #43760
PROPOSAL: #43760 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen.Recording.2024-07-08.at.16.50.46.mov
Android: mWeb Chrome
Screen.Recording.2024-07-08.at.16.55.06.mov
iOS: Native
Screen.Recording.2024-07-08.at.16.56.56.mov
iOS: mWeb Safari
Screen.Recording.2024-07-08.at.16.58.16.mov
MacOS: Chrome / Safari
Screen.Recording.2024-07-08.at.16.43.46.mov
MacOS: Desktop
Screen.Recording.2024-07-08.at.16.47.32.mov