From d8d87052da1744bd6780547b3d6869017b701fde Mon Sep 17 00:00:00 2001 From: Chowdhury Foysal Ahamed Date: Thu, 16 Jul 2026 18:37:33 +0200 Subject: [PATCH] :broom: cleanup additional question --- .../moderation/ReportDialog/index.tsx | 30 ++---- .../moderation/ReportDialog/state.test.ts | 95 ++++--------------- .../moderation/ReportDialog/state.ts | 23 ++--- 3 files changed, 34 insertions(+), 114 deletions(-) diff --git a/src/components/moderation/ReportDialog/index.tsx b/src/components/moderation/ReportDialog/index.tsx index 6854c3bd41..ddb728a082 100644 --- a/src/components/moderation/ReportDialog/index.tsx +++ b/src/components/moderation/ReportDialog/index.tsx @@ -793,10 +793,10 @@ function OptionCard({ } /** - * Qualifying questions shown when the NCII reason is selected. US residents - * reporting imagery of themselves (or on behalf of the person depicted) are - * directed to the external NCII report form; everyone else continues - * with the normal in-app submission. + * Qualifying question shown when the NCII reason is selected. The depicted + * person (or their authorized representative) is directed to the external + * NCII report form; everyone else continues with the normal in-app + * submission. */ function NciiQualification({ ncii, @@ -811,31 +811,17 @@ function NciiQualification({ return ( { dispatch({ type: 'answerNciiQuestion', - question: 'residesInUS', + question: 'isDepicted', answer, }) }} /> - {ncii.residesInUS === true && ( - { - dispatch({ - type: 'answerNciiQuestion', - question: 'isDepicted', - answer, - }) - }} - /> - )} {outcome === 'externalForm' && ( { expect(getNciiQualificationOutcome(undefined)).toBeUndefined() }) - it('is pending until questions are answered', () => { + it('is pending until the question is answered', () => { expect(getNciiQualificationOutcome({})).toBe('pending') - expect(getNciiQualificationOutcome({residesInUS: true})).toBe('pending') }) - it('directs US residents depicted in the imagery to the external form', () => { - expect( - getNciiQualificationOutcome({residesInUS: true, isDepicted: true}), - ).toBe('externalForm') + it('directs the depicted person to the external form', () => { + expect(getNciiQualificationOutcome({isDepicted: true})).toBe('externalForm') }) it('directs everyone else to in-app submission', () => { - expect(getNciiQualificationOutcome({residesInUS: false})).toBe('inApp') - expect( - getNciiQualificationOutcome({residesInUS: true, isDepicted: false}), - ).toBe('inApp') + expect(getNciiQualificationOutcome({isDepicted: false})).toBe('inApp') }) }) @@ -64,33 +58,8 @@ describe('reducer NCII qualification', () => { expect(state.ncii).toBeUndefined() }) - it('advances to step 3 for non-US residents', () => { + it('holds at step 2 for the depicted person (external form)', () => { let state = selectNciiOption() - state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', - answer: false, - }) - expect(state.activeStepIndex1).toBe(3) - }) - - it('holds at step 2 for US residents until the second answer', () => { - let state = selectNciiOption() - state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', - answer: true, - }) - expect(state.activeStepIndex1).toBe(2) - }) - - it('holds at step 2 for depicted US residents (external form)', () => { - let state = selectNciiOption() - state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', - answer: true, - }) state = reducer(state, { type: 'answerNciiQuestion', question: 'isDepicted', @@ -100,13 +69,8 @@ describe('reducer NCII qualification', () => { expect(state.activeStepIndex1).toBe(2) }) - it('advances to step 3 for non-depicted US residents', () => { + it('advances to step 3 when not the depicted person', () => { let state = selectNciiOption() - state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', - answer: true, - }) state = reducer(state, { type: 'answerNciiQuestion', question: 'isDepicted', @@ -115,52 +79,31 @@ describe('reducer NCII qualification', () => { expect(state.activeStepIndex1).toBe(3) }) - it('resets the second answer when the first changes', () => { + it('does not advance past a pending question when a labeler is auto-selected', () => { let state = selectNciiOption() state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', - answer: true, + type: 'selectLabeler', + labeler: {} as AppBskyLabelerDefs.LabelerViewDetailed, + }) + expect(state.activeStepIndex1).toBe(2) + }) + + it('skips to step 4 when the answer resolves after labeler auto-selection', () => { + let state = selectNciiOption() + state = reducer(state, { + type: 'selectLabeler', + labeler: {} as AppBskyLabelerDefs.LabelerViewDetailed, }) state = reducer(state, { type: 'answerNciiQuestion', question: 'isDepicted', - answer: true, - }) - state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', - answer: true, - }) - expect(state.ncii?.isDepicted).toBeUndefined() - expect(state.activeStepIndex1).toBe(2) - }) - - it('does not advance past pending questions when a labeler is auto-selected', () => { - let state = selectNciiOption() - state = reducer(state, { - type: 'selectLabeler', - labeler: {} as AppBskyLabelerDefs.LabelerViewDetailed, - }) - expect(state.activeStepIndex1).toBe(2) - }) - - it('skips to step 4 when answers resolve after labeler auto-selection', () => { - let state = selectNciiOption() - state = reducer(state, { - type: 'selectLabeler', - labeler: {} as AppBskyLabelerDefs.LabelerViewDetailed, - }) - state = reducer(state, { - type: 'answerNciiQuestion', - question: 'residesInUS', answer: false, }) expect(state.activeStepIndex1).toBe(4) }) it('clears NCII state when the reason or category is cleared', () => { - let state = selectNciiOption() + const state = selectNciiOption() expect(reducer(state, {type: 'clearOption'}).ncii).toBeUndefined() expect(reducer(state, {type: 'clearCategory'}).ncii).toBeUndefined() }) diff --git a/src/components/moderation/ReportDialog/state.ts b/src/components/moderation/ReportDialog/state.ts index 402ac9026c..d86b5e28b9 100644 --- a/src/components/moderation/ReportDialog/state.ts +++ b/src/components/moderation/ReportDialog/state.ts @@ -10,7 +10,6 @@ import { } from '#/components/moderation/ReportDialog/utils/useReportOptions' export type NciiQualification = { - residesInUS?: boolean isDepicted?: boolean } @@ -23,28 +22,24 @@ export type ReportState = { activeStepIndex1: number error?: string /** - * Present while the selected reason is NCII. Tracks answers to the - * qualifying questions that determine whether the report should go through + * Present while the selected reason is NCII. Tracks the answer to the + * qualifying question that determines whether the report should go through * the external NCII report form instead of in-app submission. */ ncii?: NciiQualification } /** - * Resolves the NCII qualifying questions into an outcome. US residents who - * are the depicted person (or their authorized representative) are directed - * to the external NCII report form; everyone else proceeds with the - * normal in-app submission. + * Resolves the NCII qualifying question into an outcome. The depicted person + * (or their authorized representative) is directed to the external NCII + * report form; everyone else proceeds with the normal in-app submission. */ export function getNciiQualificationOutcome( ncii?: NciiQualification, ): 'pending' | 'externalForm' | 'inApp' | undefined { if (!ncii) return undefined - if (ncii.residesInUS === false) return 'inApp' - if (ncii.residesInUS === true) { - if (ncii.isDepicted === true) return 'externalForm' - if (ncii.isDepicted === false) return 'inApp' - } + if (ncii.isDepicted === true) return 'externalForm' + if (ncii.isDepicted === false) return 'inApp' return 'pending' } @@ -142,10 +137,6 @@ export function reducer(state: ReportState, action: ReportAction): ReportState { } case 'answerNciiQuestion': { const ncii = {...state.ncii, [action.question]: action.answer} - // the second question only applies to US residents - if (action.question === 'residesInUS') { - ncii.isDepicted = undefined - } return { ...state, ncii,