Error while using outputOptions in R shiny

I have a select box in a shiny app which I am trying to use outputOptions so that it will render all the tabs in my report generated using r markdown. Below is the code for that .

observeEvent(input$tab, {
  if (input$tab == "fruits"){
    choices <- c(
      "Apples",
      "Oranges"
    )
  }
  else if (input$tab == "vegetables") {
    choices <- c(
      "potatoes",
      "squash"
    )
  }

  else {
    choices <- c(
      "berries",
      "onions"
    )
  }
  updatePickerInput(session,
                    inputId = "selected_metric",
                    choices = choices)
})

outputOptions(output, "selected_metric", suspendWhenHidden = FALSE)

The following is the error I get

Error in .subset2(x, "impl")$outputOptions(name, ...) : 
  selected_metric is not in list of output objects

I have a shiny app with 10 tabs. Each tab has 4 dropdowns where values differ based on the tab. Also each tab has a couple of tables and plots. Now I am trying to generate a report using r markdown template. The issue I get is the report would be generated only for the current tab I am on. So I used outputOptions. But it doesnt seem to work with updatePickerInput.

observeEvent(input$tab, {
  if (input$tab == "fruits"){
    choices <- c(
      "Apples",
      "Oranges"
    )
  }
  else if (input$tab == "vegetables") {
    choices <- c(
      "potatoes",
      "squash"
    )
  }

  else {
    choices <- c(
      "berries",
      "onions"
    )
  }
  updatePickerInput(session,
                    inputId = "selected_metric",
                    choices = choices)
})

outputOptions(output, "selected_metric", suspendWhenHidden = FALSE)

Error I get is

Error in .subset2(x, "impl")$outputOptions(name, ...) : 
  selected_metric is not in list of output objects

I would like to understand if this is the right way of doing it or do I have a different approach.Thank you.