Bug: feat: List merchant id and merchant name




diff --git a/crates/api_models/src/user.rs b/crates/api_models/src/user.rs
index d666dfc3bfa..07909a35782 100644
--- a/crates/api_models/src/user.rs
+++ b/crates/api_models/src/user.rs
@@ -1,4 +1,4 @@
-use common_utils::pii;
+use common_utils::{crypto::OptionalEncryptableName, pii};
 use masking::Secret;
 
 use crate::user_role::UserStatus;
@@ -133,3 +133,9 @@ pub type VerifyEmailResponse = DashboardEntryResponse;
 pub struct SendVerifyEmailRequest {
     pub email: pii::Email,
 }
+
+#[derive(Debug, serde::Serialize)]
+pub struct UserMerchantAccount {
+    pub merchant_id: String,
+    pub merchant_name: OptionalEncryptableName,
+}
diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs
index 6fb76bd75b3..532f8208ecf 100644
--- a/crates/router/src/core/user.rs
+++ b/crates/router/src/core/user.rs
@@ -640,9 +640,23 @@ pub async fn create_merchant_account(
 pub async fn list_merchant_ids_for_user(
     state: AppState,
     user: auth::UserFromToken,
-) -> UserResponse<Vec<String>> {
+) -> UserResponse<Vec<user_api::UserMerchantAccount>> {
+    let merchant_ids = utils::user_role::get_merchant_ids_for_user(&state, &user.user_id).await?;
+
+    let merchant_accounts = state
+        .store
+        .list_multiple_merchant_accounts(merchant_ids)
+        .await
+        .change_context(UserErrors::InternalServerError)?;
+
     Ok(ApplicationResponse::Json(
-        utils::user_role::get_merchant_ids_for_user(state, &user.user_id).await?,
+        merchant_accounts
+            .into_iter()
+            .map(|acc| user_api::UserMerchantAccount {
+                merchant_id: acc.merchant_id,
+                merchant_name: acc.merchant_name,
+            })
+            .collect(),
     ))
 }
 
diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rs
index 4449338402f..c474a82981b 100644
--- a/crates/router/src/utils/user_role.rs
+++ b/crates/router/src/utils/user_role.rs
@@ -18,7 +18,7 @@ pub fn is_internal_role(role_id: &str) -> bool {
         || role_id == consts::user_role::ROLE_ID_INTERNAL_VIEW_ONLY_USER
 }
 
-pub async fn get_merchant_ids_for_user(state: AppState, user_id: &str) -> UserResult<Vec<String>> {
+pub async fn get_merchant_ids_for_user(state: &AppState, user_id: &str) -> UserResult<Vec<String>> {
     Ok(state
         .store
         .list_user_roles_by_user_id(user_id)

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [X] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Added Merchant name is list merchant api.
<!-- Describe your changes in detail -->


### Additional Changes

- [x] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
Dashboard needs to show merchant name is available.
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
```
curl --location --request GET '<URL>/user/switch/list' \
--header 'Authorization: Bearer <JWT>'
```

Above api should return list of merchant accounts the user (whos jwt is being used) has access to.

```
[
    {
        "merchant_id": "merchant_1704706726",
        "merchant_name": null
    },
    {
        "merchant_id": "merchant_1704706837",
        "merchant_name": "some merchant name"
    }
]
```

 <!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
