Skip to content

Conversation

joeauyeung
Copy link
Contributor

Fix: Filter deleted booking references in EventManager methods

Summary

Fixes an issue where old booking owners still see calendar events on their calendar when a reassigned booking's location is changed. The problem occurred because the EventManager's updateLocation and deleteEventsAndMeetings methods were processing all booking references without filtering out soft-deleted ones.

Root Cause: When a booking is reassigned, the old booking references are soft-deleted (marked with deleted: true) but the EventManager methods weren't filtering these out before attempting calendar operations.

Solution: Added filtering logic to exclude deleted booking references before processing calendar updates, following the same pattern already established in the reschedule method.

Review & Testing Checklist for Human

  • End-to-end test the booking reassignment + location change flow: Create a round-robin booking, reassign it to a different user, change the location, and verify the old owner's calendar event is removed
  • Verify type safety: Confirm that adding the deleted field to PartialReference doesn't break other parts of the codebase that use this type
  • Test with real calendar integrations: Ensure the filtering works correctly with Google Calendar, Outlook, and other calendar providers
  • Check pattern consistency: Verify that the filtering logic matches the existing pattern in the reschedule method and is applied correctly in both modified methods

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    BookingReassignment["Booking Reassignment Flow"]
    EventManager["packages/lib/EventManager.ts"]:::major-edit
    TypeDef["packages/types/EventManager.d.ts"]:::major-edit
    RescheduleMethod["reschedule() method"]:::context
    UpdateLocationMethod["updateLocation() method"]:::major-edit
    DeleteEventsMethod["deleteEventsAndMeetings() method"]:::major-edit
    BookingReferences["Booking References"]:::context
    CalendarIntegrations["Calendar Integrations"]:::context
    
    BookingReassignment --> EventManager
    EventManager --> UpdateLocationMethod
    EventManager --> DeleteEventsMethod
    EventManager --> RescheduleMethod
    RescheduleMethod -.->|"pattern followed"| UpdateLocationMethod
    RescheduleMethod -.->|"pattern followed"| DeleteEventsMethod
    UpdateLocationMethod --> BookingReferences
    DeleteEventsMethod --> BookingReferences
    BookingReferences --> CalendarIntegrations
    TypeDef -.->|"type definition"| EventManager
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit  
        L3["Context/No Edit"]:::context
    end

    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

Key Changes:

  1. EventManager.ts: Added activeReferences filtering in updateLocation() and deleteEventsAndMeetings() methods to exclude references where deleted: true
  2. EventManager.d.ts: Added deleted?: boolean | null to PartialReference interface to support the filtering logic

Testing Limitations: Due to environment setup issues (ESLint configuration problems), I wasn't able to fully test the end-to-end flow locally. The type checking passed successfully, but comprehensive testing of the booking reassignment + location change scenario is needed.

Link to Devin run: https://app.devin.ai/sessions/b8cc831382df4e8f89ff1c8887bb4da2
Requested by: @joeauyeung

- Filter out soft-deleted booking references in updateLocation method
- Apply same filtering in deleteEventsAndMeetings method
- Add deleted field to PartialReference type definition
- Prevents old owners from seeing calendar events after booking reassignment and location changes
- Follows existing pattern from reschedule method

Co-Authored-By: [email protected] <[email protected]>
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

  • In packages/lib/EventManager.ts, updateLocation now filters booking.references to exclude entries with deleted truthy, using activeReferences. It uses activeReferences to find calendar references and constructs bookingWithActiveReferences to pass to updateAllCalendarEvents. In deleteEventsAndMeetings, it similarly filters bookingReferences to activeReferences and iterates over that subset.
  • In packages/types/EventManager.d.ts, interface PartialReference adds an optional field deleted?: boolean | null.
  • Net effect: calendar updates and deletions operate only on non-deleted references.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b410316 and d449dba.

📒 Files selected for processing (2)
  • packages/lib/EventManager.ts (2 hunks)
  • packages/types/EventManager.d.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1754493549-fix-reassigned-booking-location-calendar-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Aug 6, 2025
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Aug 21, 2025
@joeauyeung joeauyeung marked this pull request as ready for review September 10, 2025 15:36
@joeauyeung joeauyeung closed this Sep 10, 2025
@graphite-app graphite-app bot requested a review from a team September 10, 2025 15:36
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working labels Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants