This appears to be the query causing the permission denied error:
exec sp_executesql N'DECLARE @xml xml = @excludeList
;WITH excludeList
AS
(
SELECT T.db.value(''(./@name)[1]'', ''nvarchar(max)'') AS jobName
FROM @xml.nodes(''ExcludeList/AgentJob'') AS T(db)
)
SELECT sjv.job_id,
sjv.name,
sjv.originating_server,
sjv.description,
category = ISNULL(sc.name, FORMATMESSAGE(14205)),
owner = msdb.dbo.SQLAGENT_SUSER_SNAME(sjv.owner_sid),
sjv.enabled
FROM msdb.dbo.sysjobs_view sjv
JOIN msdb.dbo.syscategories sc
ON (sjv.category_id = sc.category_id)
left JOIN excludeList el
ON ( el.jobName LIKE ''%*%'' and sjv.name = el.jobName)
or sjv.name LIKE REPLACE(REPLACE(REPLACE(REPLACE(el.jobName, ''%'', ''[%]''), ''['', ''[[]''), ''_'', ''[_]''), ''*'', ''%'')
where el.jobName is null
ORDER BY sjv.job_id;',N'@excludeList nvarchar(15)',@excludeList=N'<ExcludeList />'