Repository: juspay/hyperswitch
File: crates/router/src/core/payments/operations/payment_response.rs (Rust)

Code before:
                            unified_code: None,
                            unified_message: None,
                            connector_transaction_id,
                            payment_method_data: None,
                            authentication_type: auth_update,
                            issuer_error_code: None,
                            issuer_error_message: None,
                            network_details: None,
                        }),
                        None,
                    )
                }
                Ok(()) => {
                    let attempt_status = payment_data.payment_attempt.status.to_owned();
                    let connector_status = router_data.status.to_owned();
                    // Check if current status is terminal and preserve it in PSync flows
                    let flow_name = core_utils::get_flow_name::<F>()?;
                    let updated_attempt_status =
                        if flow_name == "PSync" && attempt_status.is_terminal_status() {
                            // For PSync flows, if payment is already in terminal state, don't update the status
                            attempt_status
                        } else {
                            match (
                                connector_status,
                                attempt_status,
                                payment_data.frm_message.to_owned(),
                            ) {
                                (
                                    enums::AttemptStatus::Authorized,
                                    enums::AttemptStatus::Unresolved,
                                    Some(frm_message),
                                ) => match frm_message.frm_status {
                                    enums::FraudCheckStatus::Fraud
                                    | enums::FraudCheckStatus::ManualReview => attempt_status,
                                    _ => router_data.get_attempt_status_for_db_update(
                                        &payment_data,
                                        router_data.amount_captured,
                                        router_data
                                            .minor_amount_capturable
                                            .map(MinorUnit::get_amount_as_i64),
                                    )?,
                                },
                                _ => router_data.get_attempt_status_for_db_update(
                                    &payment_data,
                                    router_data.amount_captured,
                                    router_data
                                        .minor_amount_capturable
                                        .map(MinorUnit::get_amount_as_i64),
                                )?,
                            }
                        };

Review comment (suggestion):
no need of nested match cases here. we can directly have `payment_data.frm_message.frm_status.to_owned()` here, and for Fraud and ManualReview return `attempt_status`

Code after:
                            ))),
                            amount_capturable: None,
                            updated_by: storage_scheme.to_string(),
                            unified_code: None,
                            unified_message: None,
                            connector_transaction_id,
                            payment_method_data: None,
                            authentication_type: auth_update,
                            issuer_error_code: None,
                            issuer_error_message: None,
                            network_details: None,
                        }),
                        None,
                    )
                }
                Ok(()) => {
                    let attempt_status = payment_data.payment_attempt.status.to_owned();
                    let connector_status = router_data.status.to_owned();
                    let updated_attempt_status = match (
                        connector_status,
                        attempt_status,
                        payment_data.frm_message.to_owned(),
                    ) {
                        (
                            enums::AttemptStatus::Authorized,
                            enums::AttemptStatus::Unresolved,
                            Some(frm_message),
                        ) => match frm_message.frm_status {
                            enums::FraudCheckStatus::Fraud
                            | enums::FraudCheckStatus::ManualReview => attempt_status,
                            _ => router_data.get_attempt_status_for_db_update(
                                &payment_data,
                                router_data.amount_captured,
                                router_data
                                    .minor_amount_capturable
                                    .map(MinorUnit::get_amount_as_i64),
                            )?,
                        },
                        _ => router_data.get_attempt_status_for_db_update(
                            &payment_data,
                            router_data.amount_captured,
                            router_data
                                .minor_amount_capturable
                                .map(MinorUnit::get_amount_as_i64),
                        )?,
                    };
                    match payments_response {
                        types::PaymentsResponseData::PreProcessingResponse {
                            pre_processing_id,
                            connector_metadata,
                            connector_response_reference_id,