Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8cd69d2
Initial implementation of optimistic report name computation
sosek108 Jul 10, 2025
08b84d3
Introduce tests for Optimistic Report Names. Add Logging and
sosek108 Jul 11, 2025
58b5f65
Add tests for Optimistic Report Names
sosek108 Jul 11, 2025
2810b00
Introduce reassure tests
sosek108 Jul 11, 2025
7b36cbd
Merge branch 'main' into feat/optimistic-report-title
koko57 Jul 29, 2025
0d66c9c
fix: imports
koko57 Jul 31, 2025
33b27a1
chore: run prettier
koko57 Jul 31, 2025
27b9b41
fix: do not show unsupported fields, add spaces between parts
koko57 Jul 31, 2025
86ac06b
fix: minor fix
koko57 Jul 31, 2025
d7e912c
fix: add freetext to cspell
koko57 Aug 1, 2025
a16b79d
chore: rename CustomFormula to Formula, add missing spaces, adderess …
koko57 Aug 1, 2025
04755c6
fix: imports
koko57 Aug 1, 2025
03f09be
fix: date formatting
koko57 Aug 1, 2025
0b4681f
fix: revert adding spaces
koko57 Aug 1, 2025
2711fc6
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 4, 2025
9ec9e17
Rename beta to match backend value
sosek108 Aug 4, 2025
e358534
Add test cases for spaces around free text
sosek108 Aug 4, 2025
b3c7c2b
Get valid date for `startdate` formula part
sosek108 Aug 4, 2025
4339a7d
More optimal way to get oldest report action
sosek108 Aug 4, 2025
6d2a77b
startdate and created date computation. date formats
sosek108 Aug 4, 2025
c0dd1f0
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 5, 2025
4a9391f
format report types
sosek108 Aug 5, 2025
a270a9b
Use consts as typeMapping keys
sosek108 Aug 5, 2025
9e0a6bd
Centralized connection manager to use onyx values in optimistic report
sosek108 Aug 5, 2025
75f85b4
Default startdate
sosek108 Aug 5, 2025
3168ff8
Revert unwanted changes
sosek108 Aug 5, 2025
1856b71
exclude partial transactions from getOldestTransactionDate
sosek108 Aug 5, 2025
fc26fcc
domainName function
sosek108 Aug 5, 2025
4076a3a
valid report types check
sosek108 Aug 5, 2025
ecc5a1e
Small improvements, beta name correction
sosek108 Aug 5, 2025
0285d67
report filtering for policyID
sosek108 Aug 5, 2025
18481be
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 6, 2025
776e7ad
Make single path for old and new reports name computation
sosek108 Aug 6, 2025
5c92ef2
filter by __FAKE__ policyId
sosek108 Aug 6, 2025
0a68994
Explained usage of Onyx.connectWithoutView in connection mangager
sosek108 Aug 6, 2025
2bd87e8
Connection manager is initialized in async manner
sosek108 Aug 6, 2025
3ba4506
PR fixes to for testing
sosek108 Aug 6, 2025
74e08ba
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 7, 2025
d3bca5b
Removed dependency on TransactionDetails. Added comment for potentail
sosek108 Aug 7, 2025
6aa78f7
Fixed Formula tests
sosek108 Aug 7, 2025
4745680
add mock for getCurrencySymbol
sosek108 Aug 7, 2025
ddc1bf7
Proper handle of white spaces
sosek108 Aug 7, 2025
032270f
Tests fixes
sosek108 Aug 7, 2025
a4c7de6
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 8, 2025
3b8e79b
Linter fixes in test files
sosek108 Aug 8, 2025
4c91fe6
Eslint errors
sosek108 Aug 8, 2025
b0dd011
spellcheck
sosek108 Aug 8, 2025
97a35d5
typecheck errors
sosek108 Aug 8, 2025
b67b3f7
lint fixes
sosek108 Aug 8, 2025
e346148
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 8, 2025
cb998e1
comment cleanse
sosek108 Aug 8, 2025
ece6b19
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 11, 2025
739b79d
PR comment fixes
sosek108 Aug 11, 2025
f11219f
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 11, 2025
df844a5
Make OptimisticReportNames logic synchronous in prepareRequest
sosek108 Aug 11, 2025
87989c8
eslint fixes
sosek108 Aug 11, 2025
71fed6b
Skip optimisitc report name processing for OpenReport
sosek108 Aug 11, 2025
3defbcb
remove console.log
sosek108 Aug 11, 2025
c327965
chnaged default format to complain with backend
sosek108 Aug 11, 2025
64f7122
Remove tracking for transaction updates
sosek108 Aug 11, 2025
869b6ad
default date format
sosek108 Aug 11, 2025
1dc80ac
Test fixes
sosek108 Aug 11, 2025
ec2a1c1
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 11, 2025
2992150
Merge branch 'main' into feat/optimistic-report-title
sosek108 Aug 12, 2025
ad97611
PR comment fixes
sosek108 Aug 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"formatjs",
"Français",
"Frederico",
"freetext",
"frontpart",
"fullstory",
"FWTV",
Expand Down
4 changes: 4 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ const CONST = {
BETAS: {
ALL: 'all',
ASAP_SUBMIT: 'asapSubmit',
AUTH_AUTO_REPORT_TITLE: 'authAutoReportTitle',
DEFAULT_ROOMS: 'defaultRooms',
P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests',
SPOTNANA_TRAVEL: 'spotnanaTravel',
Expand Down Expand Up @@ -1513,6 +1514,9 @@ const CONST = {
APPLY_AIRSHIP_UPDATES: 'apply_airship_updates',
APPLY_PUSHER_UPDATES: 'apply_pusher_updates',
APPLY_HTTPS_UPDATES: 'apply_https_updates',
COMPUTE_REPORT_NAME: 'compute_report_name',
COMPUTE_REPORT_NAME_FOR_NEW_REPORT: 'compute_report_name_for_new_report',
UPDATE_OPTIMISTIC_REPORT_NAMES: 'update_optimistic_report_names',
COLD: 'cold',
WARM: 'warm',
REPORT_ACTION_ITEM_LAYOUT_DEBOUNCE_TIME: 1500,
Expand Down
26 changes: 24 additions & 2 deletions src/libs/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Log from '@libs/Log';
import {handleDeletedAccount, HandleUnusedOptimisticID, Logging, Pagination, Reauthentication, RecheckConnection, SaveResponseInOnyx} from '@libs/Middleware';
import {isOffline} from '@libs/Network/NetworkStore';
import {push as pushToSequentialQueue, waitForIdle as waitForSequentialQueueIdle} from '@libs/Network/SequentialQueue';
import * as OptimisticReportNames from '@libs/OptimisticReportNames';
import {getUpdateContext, initialize as initializeOptimisticReportNamesContext} from '@libs/OptimisticReportNamesConnectionManager';
import Pusher from '@libs/Pusher';
import {processWithMiddleware, use} from '@libs/Request';
import {getAll, getLength as getPersistedRequestsLength} from '@userActions/PersistedRequests';
Expand All @@ -15,7 +17,7 @@ import type OnyxRequest from '@src/types/onyx/Request';
import type {PaginatedRequest, PaginationConfig, RequestConflictResolver} from '@src/types/onyx/Request';
import type Response from '@src/types/onyx/Response';
import type {ApiCommand, ApiRequestCommandParameters, ApiRequestType, CommandOfType, ReadCommand, SideEffectRequestCommand, WriteCommand} from './types';
import {READ_COMMANDS} from './types';
import {READ_COMMANDS, WRITE_COMMANDS} from './types';

// Setup API middlewares. Each request made will pass through a series of middleware functions that will get called in sequence (each one passing the result of the previous to the next).
// Note: The ordering here is intentional as we want to Log, Recheck Connection, Reauthenticate, and Save the Response in Onyx. Errors thrown in one middleware will bubble to the next.
Expand All @@ -42,6 +44,11 @@ use(Pagination);
// middlewares after this, because the SequentialQueue depends on the result of this middleware to pause the queue (if needed) to bring the app to an up-to-date state.
use(SaveResponseInOnyx);

// Initialize OptimisticReportNames context on module load
initializeOptimisticReportNamesContext().catch(() => {
Log.warn('Failed to initialize OptimisticReportNames context');
});

let requestIndex = 0;

type OnyxData = {
Expand Down Expand Up @@ -74,7 +81,22 @@ function prepareRequest<TCommand extends ApiCommand>(
const {optimisticData, ...onyxDataWithoutOptimisticData} = onyxData;
if (optimisticData && shouldApplyOptimisticData) {
Log.info('[API] Applying optimistic data', false, {command, type});
Onyx.update(optimisticData);

// Process optimistic data through report name middleware
// Skip for OpenReport command to avoid unnecessary processing
if (command === WRITE_COMMANDS.OPEN_REPORT) {
Onyx.update(optimisticData);
} else {
try {
const context = getUpdateContext();
const processedOptimisticData = OptimisticReportNames.updateOptimisticReportNamesFromUpdates(optimisticData, context);
Onyx.update(processedOptimisticData);
} catch (error) {
Log.warn('[API] Failed to process optimistic report names', {error});
// Fallback to original optimistic data if processing fails
Onyx.update(optimisticData);
}
}
}

const isWriteRequest = type === CONST.API_REQUEST_TYPE.WRITE;
Expand Down
Loading
Loading