Repository: juspay/hyperswitch
File: crates/hyperswitch_domain_models/src/business_profile.rs (Rust)

Code before:
    #[cfg(feature = "v1")]
    pub fn get_payout_routing_algorithm(
        &self,
    ) -> CustomResult<
        Option<api_models::routing::RoutingAlgorithmRef>,
        api_error_response::ApiErrorResponse,
    > {
        self.payout_routing_algorithm
            .clone()
            .map(|val| {
                val.parse_value::<api_models::routing::RoutingAlgorithmRef>("RoutingAlgorithmRef")
            })
            .transpose()
            .change_context(api_error_response::ApiErrorResponse::InternalServerError)
            .attach_printable(
                "unable to deserialize payout routing algorithm ref from merchant account",
            )
    }

    #[cfg(feature = "v1")]
    pub fn get_frm_routing_algorithm(
        &self,
    ) -> CustomResult<
        Option<api_models::routing::RoutingAlgorithmRef>,
        api_error_response::ApiErrorResponse,
    > {
        self.frm_routing_algorithm
            .clone()
            .map(|val| {
                val.parse_value::<api_models::routing::RoutingAlgorithmRef>("RoutingAlgorithmRef")
            })
            .transpose()
            .change_context(api_error_response::ApiErrorResponse::InternalServerError)
            .attach_printable(
                "unable to deserialize frm routing algorithm ref from merchant account",
            )
    }

    pub fn get_payment_webhook_statuses(&self) -> Cow<'_, [common_enums::IntentStatus]> {
        self.webhook_details
            .as_ref()
            .and_then(|details| details.payment_statuses_enabled.as_ref())
            .filter(|statuses_vec| !statuses_vec.is_empty())
            .map(|statuses_vec| Cow::Borrowed(statuses_vec.as_slice()))
            .unwrap_or_else(|| {
                Cow::Borrowed(common_types::consts::DEFAULT_PAYMENT_WEBHOOK_TRIGGER_STATUSES)
            })
    }

    pub fn get_refund_webhook_statuses(&self) -> Cow<'_, [common_enums::RefundStatus]> {
        self.webhook_details

Review comment (suggestion):
```suggestion
pub fn get_three_ds_decision_rule_algorithm_id(
    &self,
) -> Option<common_utils::id_type::RoutingId> {
    self.three_ds_decision_rule_algorithm
        .clone()
        .and_then(|val| {
            val.parse_value::<api_models::routing::RoutingAlgorithmRef>(
                "RoutingAlgorithmRef",
            )
            .change_context(api_error_response::ApiErrorResponse::InternalServerError)
            .attach_printable(
                "unable to deserialize three_ds_decision_rule_algorithm ref from profile",
            )
            .inspect_err(|err| {
                logger::error!(
                    "Error while parsing three_ds_decision_rule_algorithm ref from profile {:?}",
                    err
                )
            })
            .ok()
        })
        .and_then(|algorithm| algorithm.algorithm_id)
}

```

can we try this and check if we can remove `.flatten()`

Code after:

    #[cfg(feature = "v1")]
    pub fn get_three_ds_decision_rule_algorithm_id(
        &self,
    ) -> Option<common_utils::id_type::RoutingId> {
        self.three_ds_decision_rule_algorithm
            .clone()
            .map(|val| {
                val.parse_value::<api_models::routing::RoutingAlgorithmRef>("RoutingAlgorithmRef")
            })
            .transpose()
            .change_context(api_error_response::ApiErrorResponse::InternalServerError)
            .attach_printable(
                "unable to deserialize three_ds_decision_rule_algorithm ref from profile",
            )
            .inspect_err(|err| {
                logger::error!(
                    "Error while parsing three_ds_decision_rule_algorithm ref from profile {:?}",
                    err
                )
            })
            .ok()
            .flatten()
            .and_then(|algorithm| algorithm.algorithm_id)
    }

    #[cfg(feature = "v1")]
    pub fn get_payout_routing_algorithm(
        &self,
    ) -> CustomResult<
        Option<api_models::routing::RoutingAlgorithmRef>,
        api_error_response::ApiErrorResponse,
    > {
        self.payout_routing_algorithm
            .clone()
            .map(|val| {
                val.parse_value::<api_models::routing::RoutingAlgorithmRef>("RoutingAlgorithmRef")
            })
            .transpose()
            .change_context(api_error_response::ApiErrorResponse::InternalServerError)
            .attach_printable(
                "unable to deserialize payout routing algorithm ref from merchant account",
            )
    }

    #[cfg(feature = "v1")]
    pub fn get_frm_routing_algorithm(
        &self,
    ) -> CustomResult<
        Option<api_models::routing::RoutingAlgorithmRef>,
        api_error_response::ApiErrorResponse,