@@ -9399,6 +9399,55 @@ describe('ReportUtils', () => {
93999399 expect(result?.actionBadge).toBe(CONST.REPORT.ACTION_BADGE.TASK);
94009400 });
94019401
9402+ it('should return the IOU badge when task action has no childManagerAccountID (backend bug before opening report)', async () => {
9403+ const iouReportID = 'iou-report-for-missing-manager';
9404+
9405+ // Task action without childManagerAccountID — simulates the backend bug
9406+ // where childManagerAccountID is missing before the report is opened
9407+ const taskAction: ReportAction = {
9408+ reportActionID: 'task-action-no-manager',
9409+ actionName: CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS,
9410+ childType: CONST.REPORT.TYPE.TASK,
9411+ childReportID: 'task-report-no-manager',
9412+ created: '2024-01-01 00:00:00',
9413+ originalMessage: {
9414+ assigneeAccountID: currentUserAccountID,
9415+ cardID: 99003,
9416+ },
9417+ };
9418+
9419+ const iouAction: ReportAction = {
9420+ reportActionID: 'iou-action-fallback',
9421+ actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
9422+ childType: CONST.REPORT.TYPE.IOU,
9423+ childReportID: iouReportID,
9424+ childManagerAccountID: currentUserAccountID,
9425+ created: '2024-01-02 00:00:00',
9426+ message: [{html: 'iou preview', text: 'iou preview', type: 'COMMENT'}],
9427+ };
9428+
9429+ const workspaceChat = {
9430+ ...createPolicyExpenseChat(42003),
9431+ hasOutstandingChildTask: true,
9432+ hasOutstandingChildRequest: true,
9433+ iouReportID,
9434+ };
9435+
9436+ await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${workspaceChat.reportID}`, workspaceChat);
9437+ await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${workspaceChat.reportID}`, {
9438+ [taskAction.reportActionID]: taskAction,
9439+ [iouAction.reportActionID]: iouAction,
9440+ });
9441+ await waitForBatchedUpdates();
9442+
9443+ const {result: isReportArchived} = renderHook(() => useReportIsArchived(workspaceChat.reportID));
9444+ const result = getReasonAndReportActionThatRequiresAttention(workspaceChat, currentUserEmail, currentUserAccountID, undefined, isReportArchived.current);
9445+
9446+ // When oldestTaskAction is undefined (no childManagerAccountID), IOU badge should be returned
9447+ expect(result?.reason).toBe(CONST.REQUIRES_ATTENTION_REASONS.HAS_CHILD_REPORT_AWAITING_ACTION);
9448+ expect(result?.reportAction?.reportActionID).toBe('iou-action-fallback');
9449+ });
9450+
94029451 it('should return the earliest matching report action for invoice rooms with missing bank account', async () => {
94039452 const invoiceRoomID = '50000';
94049453 const olderChildReportID = '50001';
0 commit comments