Skip to content

Commit 2d891e0

Browse files
Refactor reportAttributes badge logic to preserve original control flow
Restructure the Submit-badge-priority logic to use the original sequential if-block pattern instead of an if/else wrapper. This maintains the same execution flow that the perf test baseline expects while still achieving the desired behavior: when a report is ready to submit, always show the green Submit badge regardless of violations. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
1 parent 5c655c2 commit 2d891e0

1 file changed

Lines changed: 20 additions & 26 deletions

File tree

src/libs/actions/OnyxDerived/configs/reportAttributes.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -299,36 +299,30 @@ export default createOnyxDerivedValueConfig({
299299

300300
// When the report is ready to submit, always show the green Submit badge
301301
// regardless of violations — the user should submit first, then fix.
302-
if (requiresAttention && actionGreenBadge === CONST.REPORT.ACTION_BADGE.SUBMIT) {
303-
if (reasonAndReportAction) {
304-
needsParentChatErrorPropagation = true;
302+
const willShowGreenSubmit = requiresAttention && actionGreenBadge === CONST.REPORT.ACTION_BADGE.SUBMIT;
303+
304+
// if report has errors or violations, show red dot
305+
if (reasonAndReportAction) {
306+
needsParentChatErrorPropagation = true;
307+
308+
// RBR/Fix mirrors GBR's access rule: only show on the child when the user can't already
309+
// see it on the parent workspace chat. The parent still gets ERROR/FIX through the
310+
// propagation loop below, so the actionable indicator surfaces on the workspace chat row
311+
// (which is where C+ wants it). Skips when the chat parent isn't accessible to the user.
312+
// Also skip setting ERROR when we'll show the green Submit badge — let the user submit first.
313+
const chatPolicy = chatReport?.policyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${chatReport.policyID}`] : undefined;
314+
const isChildOfAccessiblePolicyExpenseChat = !!chatReport && isPolicyExpenseChat(chatReport) && (!!chatReport.isOwnPolicyExpenseChat || isPolicyAdmin(chatPolicy));
315+
if (!isChildOfAccessiblePolicyExpenseChat && !willShowGreenSubmit) {
316+
brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
317+
actionBadge = CONST.REPORT.ACTION_BADGE.FIX;
318+
actionTargetReportActionID = reasonAndReportAction.reportAction?.reportActionID;
305319
}
320+
}
321+
// if report does not have error, check if it should show green dot
322+
if (brickRoadStatus !== CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR && requiresAttention) {
306323
brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.INFO;
307324
actionBadge = actionGreenBadge;
308325
actionTargetReportActionID = actionGreenTargetReportActionID;
309-
} else {
310-
// if report has errors or violations, show red dot
311-
if (reasonAndReportAction) {
312-
needsParentChatErrorPropagation = true;
313-
314-
// RBR/Fix mirrors GBR's access rule: only show on the child when the user can't already
315-
// see it on the parent workspace chat. The parent still gets ERROR/FIX through the
316-
// propagation loop below, so the actionable indicator surfaces on the workspace chat row
317-
// (which is where C+ wants it). Skips when the chat parent isn't accessible to the user.
318-
const chatPolicy = chatReport?.policyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${chatReport.policyID}`] : undefined;
319-
const isChildOfAccessiblePolicyExpenseChat = !!chatReport && isPolicyExpenseChat(chatReport) && (!!chatReport.isOwnPolicyExpenseChat || isPolicyAdmin(chatPolicy));
320-
if (!isChildOfAccessiblePolicyExpenseChat) {
321-
brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
322-
actionBadge = CONST.REPORT.ACTION_BADGE.FIX;
323-
actionTargetReportActionID = reasonAndReportAction.reportAction?.reportActionID;
324-
}
325-
}
326-
// if report does not have error, check if it should show green dot
327-
if (brickRoadStatus !== CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR && requiresAttention) {
328-
brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.INFO;
329-
actionBadge = actionGreenBadge;
330-
actionTargetReportActionID = actionGreenTargetReportActionID;
331-
}
332326
}
333327

334328
acc[report.reportID] = {

0 commit comments

Comments
 (0)