Skip to content

Scheduling infrastructure for absolutely everyone.

fix: hide OOO slots across timezones (#25966)

Udit Takkar68e670ae065d
diff --git a/packages/features/schedules/lib/slots.test.ts b/packages/features/schedules/lib/slots.test.ts
index 1187d819dba..62b2742108f 100644
--- a/packages/features/schedules/lib/slots.test.ts
+++ b/packages/features/schedules/lib/slots.test.ts
@@ -874,9 +874,9 @@ describe("Tests the date-range slot logic with showOptimizedSlots", () => {
},
],
datesOutOfOffice,
+ datesOutOfOfficeTimeZone: "UTC",
});
- // Filter slots by day
const day1Slots = slots.filter((slot) => slot.time.format("YYYY-MM-DD") === "2025-11-17");
const day2Slots = slots.filter((slot) => slot.time.format("YYYY-MM-DD") === "2025-11-18");
@@ -925,6 +925,7 @@ describe("Tests the date-range slot logic with showOptimizedSlots", () => {
eventLength: 30,
dateRanges,
datesOutOfOffice,
+ datesOutOfOfficeTimeZone: "Europe/Berlin",
});
expect(slots.length).toBeGreaterThan(0);
@@ -1011,4 +1012,46 @@ describe("Tests the date-range slot logic with showOptimizedSlots", () => {
vi.useRealTimers();
});
+
+ it("should mark slots as away when host OOO day maps to next UTC day (LA host, Kolkata booker)", async () => {
+ vi.setSystemTime(dayjs.utc("2026-01-10T00:00:00Z").toDate());
+
+ const datesOutOfOffice = {
+ "2026-01-16": {
+ fromUser: { id: 1, displayName: "Host User" },
+ toUser: null,
+ reason: "OOO",
+ emoji: "🏖️",
+ },
+ };
+
+ const dateRanges = [
+ {
+ start: dayjs.tz("2026-01-16T16:00:00", "America/Los_Angeles"),
+ end: dayjs.tz("2026-01-16T17:00:00", "America/Los_Angeles"),
+ },
+ ];
+
+ const inviteeDate = dayjs.tz("2026-01-17T00:00:00", "Asia/Kolkata");
+
+ const slots = getSlots({
+ inviteeDate,
+ frequency: 30,
+ minimumBookingNotice: 0,
+ eventLength: 30,
+ dateRanges,
+ datesOutOfOffice,
+ datesOutOfOfficeTimeZone: "America/Los_Angeles",
+ });
+
+ const targetSlot = slots.find(
+ (slot) => slot.time.tz("Asia/Kolkata").format("YYYY-MM-DD HH:mm") === "2026-01-17 05:30"
+ );
+
+ expect(targetSlot).toBeDefined();
+ expect(targetSlot?.away).toBe(true);
+ expect(targetSlot?.reason).toBe("OOO");
+
+ vi.useRealTimers();
+ });
});
diff --git a/packages/features/schedules/lib/slots.ts b/packages/features/schedules/lib/slots.ts
index e649a6e8551..a8733fecf95 100644
--- a/packages/features/schedules/lib/slots.ts
+++ b/packages/features/schedules/lib/slots.ts
@@ -18,6 +18,7 @@ export type GetSlots = {
offsetStart?: number;
datesOutOfOffice?: IOutOfOfficeData;
showOptimizedSlots?: boolean | null;
+ datesOutOfOfficeTimeZone?: string;
};
export type TimeFrame = { userIds?: number[]; startTime: number; endTime: number };
@@ -76,6 +77,7 @@ function buildSlotsWithDateRanges({
offsetStart,
datesOutOfOffice,
showOptimizedSlots,
+ datesOutOfOfficeTimeZone,
}: {
dateRanges: DateRange[];
frequency: number;
@@ -85,6 +87,7 @@ function buildSlotsWithDateRanges({
offsetStart?: number;
datesOutOfOffice?: IOutOfOfficeData;
showOptimizedSlots?: boolean | null;
+ datesOutOfOfficeTimeZone?: string;
}) {
// keep the old safeguards in; may be needed.
frequency = minimumOfOne(frequency);
@@ -180,8 +183,15 @@ function buildSlotsWithDateRanges({
}
slotBoundaries.set(slotStartTime.valueOf(), true);
- const slotDateYYYYMMDD = slotStartTime.utc().format("YYYY-MM-DD");
- const dateOutOfOfficeExists = datesOutOfOffice?.[slotDateYYYYMMDD];
+
+ let dateOutOfOfficeExists = undefined;
+ if (datesOutOfOffice) {
+ const slotDateYYYYMMDD = datesOutOfOfficeTimeZone
+ ? slotStartTime.tz(datesOutOfOfficeTimeZone).format("YYYY-MM-DD")
+ : slotStartTime.utc().format("YYYY-MM-DD");
+ dateOutOfOfficeExists = datesOutOfOffice?.[slotDateYYYYMMDD];
+ }
+
let slotData: {
time: Dayjs;
userIds?: number[];
@@ -228,6 +238,7 @@ const getSlots = ({
offsetStart = 0,
datesOutOfOffice,
showOptimizedSlots,
+ datesOutOfOfficeTimeZone,
}: GetSlots): {
time: Dayjs;
userIds?: number[];
@@ -246,6 +257,7 @@ const getSlots = ({
offsetStart,
datesOutOfOffice,
showOptimizedSlots,
+ datesOutOfOfficeTimeZone,
});
};
diff --git a/packages/trpc/server/routers/viewer/slots/util.ts b/packages/trpc/server/routers/viewer/slots/util.ts
index 764358584d6..6a564705bb6 100644
--- a/packages/trpc/server/routers/viewer/slots/util.ts
+++ b/packages/trpc/server/routers/viewer/slots/util.ts
@@ -1203,6 +1203,7 @@ export class AvailableSlotsService {
frequency: eventType.slotInterval || input.duration || eventType.length,
datesOutOfOffice: !isTeamEvent ? allUsersAvailability[0]?.datesOutOfOffice : undefined,
showOptimizedSlots: eventType.showOptimizedSlots,
+ datesOutOfOfficeTimeZone: !isTeamEvent ? allUsersAvailability[0]?.timeZone : undefined,
});
let availableTimeSlots: typeof timeSlots = [];