Mike McMahan wrote Lower Decks cameo-filled finale before the legacy actors had committed to the show