@@ -201,23 +201,34 @@ export function inferMemberOrganizationStintChanges(
201201 continue
202202 }
203203
204- // 5. Determine the gap window between neighbor and targetDate, then check if another org
205- // holds a significant (>= 30 day) dated stint that overlaps that window (multi- stint guard)
204+ // 5. Only split when another org clearly sits between this stint and the new date.
205+ // Overlapping orgs are treated as concurrent evidence, not a break in the stint.
206206 const isForward = targetDate > neighbor . dateEnd
207- const gapStart = isForward ? neighbor . dateEnd : targetDate
208- const gapEnd = isForward ? targetDate : neighbor . dateStart
209- const hasConflict = stints . some (
210- ( s ) =>
211- s . organizationId !== organizationId &&
212- s . dateStart &&
213- s . dateEnd &&
214- s . dateStart < gapEnd &&
215- s . dateEnd > gapStart &&
216- diff ( s . dateStart , s . dateEnd ) >= 30 ,
217- )
207+ const hasSeparator = stints . some ( ( s ) => {
208+ if (
209+ s . organizationId === organizationId ||
210+ ! s . dateStart ||
211+ ! s . dateEnd ||
212+ diff ( s . dateStart , s . dateEnd ) < 30
213+ ) {
214+ return false
215+ }
216+
217+ if ( isForward ) {
218+ return (
219+ ( s . dateStart > neighbor . dateEnd && s . dateStart <= targetDate ) ||
220+ ( s . dateEnd > neighbor . dateEnd && s . dateEnd <= targetDate )
221+ )
222+ }
223+
224+ return (
225+ ( s . dateStart >= targetDate && s . dateStart < neighbor . dateStart ) ||
226+ ( s . dateEnd >= targetDate && s . dateEnd < neighbor . dateStart )
227+ )
228+ } )
218229
219- if ( hasConflict ) {
220- // 6a. Another org owns the gap — start a fresh stint rather than bridging
230+ if ( hasSeparator ) {
231+ // 6a. Another org clearly sits in between — start a fresh stint rather than bridging
221232 stints . push ( {
222233 id : null ,
223234 organizationId,
0 commit comments