-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Add red dot to one transaction reports #44810
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
Changes from all commits
7da324b
7ab06d9
39f8fed
1bef82d
805f6ae
20f24c7
d8e6c25
4e1d2de
9c8ef36
9392dc9
c35d1e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,11 +18,18 @@ import localeCompare from './LocaleCompare'; | |||||||
| import * as LocalePhoneNumber from './LocalePhoneNumber'; | ||||||||
| import * as Localize from './Localize'; | ||||||||
| import * as OptionsListUtils from './OptionsListUtils'; | ||||||||
| import Permissions from './Permissions'; | ||||||||
| import * as PolicyUtils from './PolicyUtils'; | ||||||||
| import * as ReportActionsUtils from './ReportActionsUtils'; | ||||||||
| import * as ReportUtils from './ReportUtils'; | ||||||||
| import * as TaskUtils from './TaskUtils'; | ||||||||
|
|
||||||||
| let allBetas: OnyxEntry<Beta[]>; | ||||||||
| Onyx.connect({ | ||||||||
| key: ONYXKEYS.BETAS, | ||||||||
| callback: (value) => (allBetas = value), | ||||||||
| }); | ||||||||
|
|
||||||||
| const visibleReportActionItems: ReportActions = {}; | ||||||||
| Onyx.connect({ | ||||||||
| key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||||||||
|
|
@@ -94,8 +101,17 @@ function getOrderedReportIDs( | |||||||
| const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; | ||||||||
| const isFocused = report.reportID === currentReportId; | ||||||||
| const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; | ||||||||
| const transactionReportActions = ReportActionsUtils.getAllReportActions(report.reportID); | ||||||||
| const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, transactionReportActions, undefined); | ||||||||
| let doesTransactionThreadReportHasViolations = false; | ||||||||
| if (oneTransactionThreadReportID) { | ||||||||
| const transactionReport = ReportUtils.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')); | ||||||||
| if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0', parentReportAction)) { | ||||||||
| return; | ||||||||
| } | ||||||||
|
|
@@ -214,6 +230,7 @@ function getOptionData({ | |||||||
| policy, | ||||||||
| parentReportAction, | ||||||||
| hasViolations, | ||||||||
| transactionViolations, | ||||||||
| }: { | ||||||||
| report: OnyxEntry<Report>; | ||||||||
| reportActions: OnyxEntry<ReportActions>; | ||||||||
|
|
@@ -222,6 +239,7 @@ function getOptionData({ | |||||||
| policy: OnyxEntry<Policy> | undefined; | ||||||||
| parentReportAction: OnyxEntry<ReportAction> | undefined; | ||||||||
| hasViolations: boolean; | ||||||||
| transactionViolations?: OnyxCollection<TransactionViolation[]>; | ||||||||
| }): ReportUtils.OptionData | undefined { | ||||||||
| // When a user signs out, Onyx is cleared. Due to the lazy rendering with a virtual list, it's possible for | ||||||||
| // this method to be called after the Onyx data has been cleared out. In that case, it's fine to do | ||||||||
|
|
@@ -281,6 +299,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)); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 App/src/components/LHNOptionsList/OptionRowLHNData.tsx Lines 37 to 39 in dd96852
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);
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should let the
cc @robertjchen What do you think?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok 👍 |
||||||||
| if (oneTransactionThreadReportID) { | ||||||||
| const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID); | ||||||||
|
|
||||||||
| if ( | ||||||||
| Permissions.canUseViolations(allBetas) && | ||||||||
| ReportUtils.shouldDisplayTransactionThreadViolations( | ||||||||
| oneTransactionThreadReport, | ||||||||
| transactionViolations, | ||||||||
| ReportActionsUtils.getAllReportActions(report.reportID)[oneTransactionThreadReport?.parentReportActionID ?? '-1'], | ||||||||
| ) | ||||||||
| ) { | ||||||||
| result.brickRoadIndicator = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; | ||||||||
| } | ||||||||
| } | ||||||||
| result.ownerAccountID = report.ownerAccountID; | ||||||||
| result.managerID = report.managerID; | ||||||||
| result.reportID = 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
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.tsis 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 movegetReportthere, though it is the same.Thoughts @robertjchen ?