Object 'state' not found - Advanced Bookmarking

I'm trying to implement some advanced bookmarking in a modularized Shiny application using the Rhino framework. Due to use of the shiny.fluent package not being firendly with bootstrap, I've needed to create my own button to initiate the bookmark and write the subsequent onBookmark, onRestore, onBookmarked callbacks. I've supplied the code below that's relevant. When I click the button after selecting some inputs and entering values, I keep recieveing the error "object 'state' not found" leading me to believe this is some kind of namespacing issue within the modules? Any help is greatly appreciated!

main.R:

## shiny is loaded in its entirety along with necessary functions from shiny.fluent with the box package at the top of this code

## enable Shiny bookmarking ----
enableBookmarking(store = 'url')

....

## Export server functions from modules to app ----
#' @export
server <- function(id) {
  moduleServer(id, function(input, output, session) {
   ... run server functions of all other modules to interact with main.R ...

  ## Update URL onBookmarked
  ## Create modal pop up to display info and allow for copy or copy button ----
  onBookmarked(function(url) {
    updateQueryString(url)
    
    ## Create modal to display bookmark info ----
    showModal(
      Dialog(
        div(
          TextField(url, readOnly = TRUE)
        ),
        isOpen = T,
        DialogFooter(
          Text('This link stores the current state of this application. Press Ctrl-C to copy.')
        )
      )
    )
  })
}

data.R:

## Create UI for the data pane ----
#' @export
ui <- function(id, ui_chosen) { 
  ns <- NS(id)
  tagList(
    div( # Container to group UI elements together
      ActionButton.shinyInput(
        inputId = ns('bookmarkbtn'),
        iconProps = list('iconName' = 'AddBookmark'),
        text = 'Save Query URL',
        className = 'submitsql'
      )
... remainder of UI function

server <- function(id, vals, view_tables, agg, table, telemetry, filter_list) {
  moduleServer(id, function(input, output, session) {
    
    ## Set namespace for the session so names are not overlapped ----
    ns <- session$ns
    
  ... necessary server function for data.R module ...
    
    observeEvent(input[['bookmarkbtn']], {
      ## Create bookmark on button click ----
      reactiveValuesToList(input)

    ## Bookmark functions to save and restore values ----
    if(length(vals) >= 1) {
      onBookmark(function(state) {
        state$values$table <<- table # used to bookmark selected table/view
        state$values$vals <<- vals # used to bookmark selected columns (dat$cols) and filters (dat$filters)
        state$values$agg <<- agg # used to bookmark if aggregation or not
        state$values$filter_list <<- filter_list # used to bookmark selected filters and their stage (added, removed, same)
      })
    }

    ## When app restores from URL, reset reactiveValues to their saved state ----
    onRestore(function(state) {
      table <<- state$values$table # used to restore selected table/view
      dat <<- state$values$vals # used to restore selected columns (dat$cols) and filters (dat$filters)
      agg <<- state$values$agg # used to restore if aggregation or not
      filter_list <<- state$values$filter_list # used to restore selected filters and their stage (added, removed, same)
    })

    ## Set exclusion for
    setBookmarkExclude(c('bookmarkbtn'))
    
    ## Call bookmark function
    session$doBookmark()
  })
})
}