How to get rid of null element in local var list. compact didn't work

I have tried using compact. Since a local variable has mulitple {} values, it does not work

returns this error

 local.policymerge is tuple with 49 elements

Invalid value for "list" parameter: element 0: string required.

locals {
    policymerge= flatten([
    for i in local.policylist  : [
      for j in data.azurerm_policy_definition.example : {
        name   = "${i.name == j.display_name  ? i.name : null}"
        id = "${i.name == j.display_name  ? j.id : null}"
        fname = "${i.name == j.display_name  ? i.fname : null}"
      }
    ]
  ])

   
}


output "t" {
  value = local.policymerge
}


Outputs:

t = [
  {
    "fname" = "xxx"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/95edb821-ddaf-4404-9732-xxxx"
    "name" = "xxxr"
  },
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {
    "fname" = "xxx"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/1a5b4dca-0b6f-4cf5-907c-xxxx"
    "name" = "xxxx"
  },
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {
    "fname" = "xxx"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/3fc4dc25-5baf-40d8-9b05-xxx"
    "name" = "xxx"
  },
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {
    "fname" = "xxx"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/febd0533-8e55-448f-b837-xxx"
    "name" = "xxx"
  },
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {
    "fname" = "xxx-IPC"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/47a1ee2f-2a2a-4576-bf2a-xxx"
    "name" = "xxx"
  },
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {
    "fname" = "xxx"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/df49d893-a74c-421d-bc95-xxxx"
    "name" = "xxx"
  },
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {
    "fname" = "xxx"
    "id" = "/providers/Microsoft.Authorization/policyDefinitions/1c6e92c9-99f0-4e55-9cf2-xxx"
    "name" = "xxx"
  },
]