diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java index 7fdad8616..7025cc0a2 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/response/JurorOverviewResponseDto.java @@ -127,7 +127,7 @@ public JurorOverviewResponseDto(JurorPool jurorPool, if (todayAppearance.isPresent() && todayAppearance.get().getTimeOut() != null) { this.location = null; } else { - this.location = getLocationFromPanel(panelRepository, jurorPool); + this.location = getLocationFromPanel(panelRepository, jurorPool, this.checkedInTodayTime != null); } @@ -158,12 +158,16 @@ public JurorOverviewResponseDto(JurorPool jurorPool, } @JsonIgnore - private String getLocationFromPanel(PanelRepository panelRepository, JurorPool jurorPool) { - return getActivePanel(panelRepository, jurorPool) - .map(panel -> panel.getTrial().getCourtroom().getDescription()) - .orElse(Optional.ofNullable(jurorPool.getCourt().getAssemblyRoom()) + private String getLocationFromPanel(PanelRepository panelRepository, JurorPool jurorPool, boolean hasAppearance) { + Optional locationFromPanel = getActivePanel(panelRepository, jurorPool) + .map(panel -> panel.getTrial().getCourtroom().getDescription()); + + if (locationFromPanel.isPresent() || !hasAppearance) { + return locationFromPanel.orElse(null); + } + return Optional.ofNullable(jurorPool.getCourt().getAssemblyRoom()) .map(Courtroom::getDescription) - .orElse(null)); + .orElse(null); } private Optional getActivePanel(PanelRepository panelRepository, JurorPool jurorPool) {