You could revise your second code snippet to make it much more concise.
std::expected<std::string, ErrorType> optional_to_expected(std::optional<int> opt) {
if (opt) {
return std::to_string(*opt);
}
return std::unexpected(ErrorType());
}