I choose to believe that the kiss that ended the episode restored her memories. Otherwise, yes, completely ruins five seasons of character development. Sarah was clearly remembering more and more bits and pieces of her lost memories as the finale progressed. The final kiss was Morgan's cheesy idea, and throughout the series, his cheesy ideas were always right.