While transformation into the Red Hood. However, it is possible that even before the events of Under the Red Hood were set in motion, Jason’s return was always his fate.
After Dick Grayson left Gotham and became Nightwing, Batman quickly found his replacement in Jason Todd, the short-lived second Robin. While Nightwing's original opinion of Jason Todd was not stellar, Dick was deeply affected by Jason’s death. In the years following his murder, Jason’s tattered Robin costume was memorialized in the Batcave, serving as a grim reminder of the high stakes of heroism and Batman’s failure to save his partner.
Before his return as the Red Hood, Nightwing: Secret Files and Origins' 'Taking Wing,' from Chuck Dixon and Scott McDaniel plays with Jason’s haunting legacy, having him appear to Dick as an apparition after a near-death experience renders Nightwing unconscious. Dressed as Robin, Jason Todd guides Nightwing through his memories while the two piece together the events that led to the creation of his identity. The bizarre journey takes an even stranger turn when Jason decides to leave, saying, “See you around, Grayson,” to which a hazy Dick replies, “You too, Jason.” The story plays with the idea of whether Jason is a hallucination or a true apparition, but with not just one but many afterlives confirmed to exist in the DC Universe, there's no reason to doubt it's the latter.
A significant hint that Dick’s “hallucination” is genuinely Jason’s spirit is the dialogue between the two as they part ways. Jason’s insistence that he’ll see Dick soon suggests either that Nightwing doesn't have long to live, or that Jason's spirit is keeping an eye on him and will return in the future. It is also important to note the way Jason is depicted in Dick’s "dream." With most of his features blocked out by shadows, and glowing red eyes, Jason’s ghost looks sinister. Such a dark portrayal could be another nod towards Jason's fate, as Red Hood came back with a staggering amount of rage.
By the time Dick wakes up, Jason has disappeared, but his effect is instantaneous as Nightwing prepares to spring into action. In a moment when Dick was at his lowest and would have lost his life if he's stayed unconscious, Jason’s spirit stepped forward, reminding him of why he chose to become a hero. For Jason to know that his brother needed help, he likely had been watching over Dick, suggesting that his spirit never moved on - a detail that sadly makes more sense than his spirit finding peace. Jason Todd’s persistent connection to the Bat-Family even while dead indicates that he was always destined to return to them.
While this story had no way of knowing Jason Todd would one day return, the implication that he still existed in spirit, watching over the Bat-Family is a fascinating detail that speaks to the events between his death and later resurrection. With connections to mysticism many forget, it's easy to imagine that in failing to move on, Jason Todd was always just waiting for his opportunity to return to life as the vicious Red Hood.